bestpractices.adoc 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. [#bestpractices]
  2. = Best Practices for Deployment
  3. [abstract]
  4. Recommended practices for moving Neo4j into production in Kubernetes environments
  5. [NOTE]
  6. This material covers only Kubernetes specifics of running Neo4j. Other best practices for Neo4j apply, and should be consulted.
  7. == Use the Best Storage Available
  8. This comes in two pieces:
  9. * The highest `storageClass` for your persistent volume claims, ideally solid state disks
  10. * Large disks (possibly larger than you need) to ensure that you get high IOPS/throughput
  11. In cloud environments, small disks typically get less throughput. Neo4j performance is very
  12. sensitive to the storage layer's performance, so make sure you have disk that is as fast as possible.
  13. == Set CPU & Memory Requests and Limits
  14. Prior to production deploy, you should size your Neo4j workload so that your needed CPU and memory
  15. can be known ahead of time. Ensure that your CPU requests and limits are set, and that they are
  16. the same, to prevent kubernetes resource "bursting" from being used, and to ensure that the
  17. database has a consistent set of available resources.
  18. In particular, *avoid large differences between memory request and limits*. In certain scenarios,
  19. this can lead to Kubernetes killing your pods, when the worker node comes under memory pressure.
  20. == Use ConfigMaps for explicit configuration
  21. By configuring Neo4j with an external `ConfigMap` you can be explicit about any aspect of your
  22. database configuration, which you can later version & change using Kubernetes built-in tools.
  23. == Use Anti-Affinity Rules
  24. Following the examples provided in this manual, define anti-affinity rules to spread out your
  25. Neo4j cluster members across worker nodes. This applies to Causal Cluster, and helps ensure
  26. that your Neo4j deployment will be highly available, since the cluster will continue to function
  27. even if an underlying Kubernetes worker node fails.
  28. == Front your Pods with Backup and Restore
  29. We strongly suggest you use regularly scheduled backups in some form (examples are provided in this
  30. repo) and that all new pods start with a restore from the last backup. This provides many benefits:
  31. * Consistently scheduled backups are a basic best practice
  32. * Faster recovery during failure
  33. * Data safety even if the cluster runs into trouble
  34. * Faster startup time for new machines, because they have less state to catch up on
  35. * Easier ability to scale by adding a new read replica, if needed
  36. * Less load on the core members, who do not need to replicate database state to a new
  37. cluster member "starting cold"