tuning.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. .. _tuning:
  2. .. include:: global.rst.inc
  3. Tuning
  4. ======
  5. General hints
  6. -------------
  7. CPU load, backup speed, memory and storage usage are covered below.
  8. As performance and resource usage depend on a lot of factors, you may need to
  9. tweak the parameters a bit and retry until you found the best ones for your
  10. setup.
  11. Usually, the default parameters are selected for best speed under the assumption
  12. that you run a modern machine with fast CPU, fast I/O and a good amount of RAM.
  13. If you run an older or low-resource machine or your backup target or connection
  14. to it is slow, tweaking parameters might give significant speedups.
  15. Exclude crap data
  16. -----------------
  17. Maybe you don't want to backup:
  18. * cache / temporary files (they can be rebuilt / are useless)
  19. * specific directories / filenames / file extensions you do not need
  20. * backups (some people make backups of backups...)
  21. You can exclude these, so they don't waste time and space.
  22. Avoid scrolling
  23. ---------------
  24. If you do benchmarks, avoid creating a lot of log output, especially if it
  25. means scrolling text in a window on a graphical user interface.
  26. Rather use much less log output or at least redirect the output to a log file,
  27. that is also much faster than scrolling.
  28. Speed (in general)
  29. ------------------
  30. Keep an eye on CPU and I/O bounds. Try to find the sweet spot in the middle
  31. where it is not too much I/O bound and not too much CPU bound.
  32. I/O bound
  33. ~~~~~~~~~
  34. If CPU load does not sum up to 1 core fully loaded while backing up, the
  35. process is likely I/O bound (can't read or write data fast enough).
  36. Maybe you want to try higher compression then so it has less data to write.
  37. Or get faster I/O, if possible.
  38. CPU bound
  39. ~~~~~~~~~
  40. If you have 1 core fully loaded most of the time, but your backup seems slow,
  41. the process is likely CPU bound (can't compute fast enough).
  42. Maybe you want to try lower compression then so it has less to compute.
  43. Using a faster MAC or cipher method might also be an option.
  44. Or get a faster CPU.
  45. I/O speed
  46. ---------
  47. From fast to slower:
  48. * fast local filesystem, SSD or HDD, via PCIe, SATA, USB
  49. * ssh connection to a remote server's borg instance
  50. * mounted network filesystems of a remote server
  51. Not only throughput influences timing, latency does also.
  52. Backup space needed
  53. -------------------
  54. If you always backup the same data mostly, you will often save a lot of space
  55. due to deduplication - this works independently from compression.
  56. To avoid running out of space, regularly prune your backup archives according
  57. to your needs. Backups of same machine which are close in time are usually
  58. very cheap (because most data is same and deduplicated).
  59. Compression
  60. -----------
  61. If you have a fast backup source and destination and you are not low on backup space:
  62. Switch off compression, your backup will run faster and with less cpu load.
  63. If you just want to save a bit space, but stay relatively fast:
  64. Try zlib level 1.
  65. If you have very slow source or destination (e.g. a remote backup space via a
  66. network connection that is quite slower than your local and remote storage):
  67. Try a higher zlib or lzma.
  68. Authentication & MAC selection
  69. ------------------------------
  70. Real MACs (Message Authentication Codes) can only be used when a secret key is
  71. available. It is signing your backup data and can detect malicious tampering.
  72. Without a key, a simple hash will be used (which helps to detect accidental
  73. data corruption, but can not detect malicious data tampering).
  74. Older or simple 32bit machine architecture
  75. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  76. Use sha256 (no key) or hmac-sha256 (key).
  77. 64bit architecture, but no AES hardware acceleration in the CPU
  78. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  79. Use sha512-256 (no key) or hmac-sha512-256 (key).
  80. Modern 64bit CPU with AES hardware acceleration (AES-NI, PCLMULQDQ)
  81. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  82. Use ghash (no key) or gmac (key).
  83. Encryption & Cipher selection
  84. -----------------------------
  85. Always encrypt your backups (and keep passphrase and key file [if any] safe).
  86. The cipher selection chooses between misc. AEAD ciphers (authenticated
  87. encryption with associated data), it is EtM (encrypt-then-mac):
  88. Older or simple 32bit machine architecture
  89. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  90. Use aes256-ctr + hmac-sha256.
  91. 64bit architecture, but no AES hardware acceleration in the CPU
  92. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  93. Use aes256-ctr + hmac-sha512-256.
  94. Modern 64bit CPU with AES hardware acceleration (AES-NI, PCLMULQDQ)
  95. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  96. Use aes256-gcm (AEAD 1-pass cipher).
  97. RAM usage
  98. ---------
  99. Depending on the amount of files and chunks in the repository, memory usage
  100. varies:
  101. * about 250+B RAM per file (for "files" cache)
  102. * about 44B RAM per 64kiB chunk (for "chunks" cache)
  103. * about 40B RAM per 64kiB chunk (for repository index, if remote repo is used,
  104. this will be allocated on remote side)
  105. If you run into memory usage issues, your options are:
  106. * get more RAM (or more swapspace, speed will be slower)
  107. * disable the "files" cache, speed will be slower
  108. * have less files / chunks per repo
  109. Note: RAM compression likely won't help as a lot of that data is using
  110. msgpack, which is already rather efficient.