Advertisement
Wolfbeast

Sync server high volume use

May 29th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.90 KB | None | 0 0
  1. # High-volume use of the sync server
  2.  
  3. If you have a lot of users for your sync server, there are a few tweaks/setup considerations you need to have a look at. This is because the way the sync server is designed, most data is in a single, large table that gets constantly updated.
  4.  
  5. ## Database setup
  6.  
  7. To deal with high-volume use on the database side, you need to:
  8.  
  9. * Use a real database server (MySQL). SQLite does not suffice for more than small organizations.
  10. * Use InnoDB for your sync tables. This is required because sync has lots of writes/updates, MyISAM locks the entire table when updating, and you'll end up with overflowing queues/service refusal otherwise.
  11. * Configure the MySQL server correctly (see below).
  12. * Perform regular maintenance on the tables/indices.
  13.  
  14. ### MySQL server configuration
  15.  
  16. The database server should be set up to handle the specific requirements of the sync server, which is a large number of insert/update/replace operations per user (typical usage sees more writes than reads which is not your average database use that is more reads than writes).
  17. It is recommended to use the [barracuda](https://dev.mysql.com/doc/refman/5.5/en/innodb-file-format.html) file format and its `DYNAMIC` row format for the `wbo` table.
  18. You should use separate files per table to deal with the data churn effectively and be able to reclaim disk space properly when performing maintenance.
  19.  
  20. Example configuration:
  21. ````
  22. [mysqld]
  23. datadir = /var/lib/mysql
  24. socket = /var/lib/mysql/mysql.sock
  25. tmpdir = /tmp
  26. user=mysql
  27.  
  28. symbolic-links = 0
  29. sync_binlog = 0
  30.  
  31. # Allow the wbo table to grow as-needed (it will get very large)
  32. big-tables
  33.  
  34. # If you require ACID compliance, you need to leave the following setting to default.
  35. innodb_flush_log_at_trx_commit = 2
  36.  
  37. # Adjust the following according to your processing capabilities, keep it on the low end.
  38. innodb_thread_concurrency = 2
  39. thread_cache_size = 4
  40.  
  41. # Speed up writes, See MySQL documentation
  42. innodb_doublewrite = 0
  43.  
  44. # Very important: this should be 2/3-3/4 of your available RAM in the server
  45. innodb_buffer_pool_size = 4096M
  46.  
  47. # Adjust as needed to buffer concurrent updates
  48. innodb_log_file_size = 256M
  49. innodb_log_buffer_size = 64M
  50.  
  51. # io: min 100 def 200 -- adjust this to match your write I/O capacity of your hardware
  52. innodb_io_capacity = 600
  53.  
  54. ;performance_schema
  55. innodb_file_per_table = 1
  56. innodb_file_format = barracuda
  57.  
  58. key_buffer_size = 24M
  59. query_cache_limit = 4M
  60. query_cache_size = 256M
  61. query_cache_type = 1
  62. ````
  63.  
  64. ### Database maintenance
  65.  
  66. Indices should be key-balanced on a nightly schedule if you have more than 10,000 users to prevent fragmentation and runaway I/O on your database.
  67. This is best done using a cron job with the following command (e.g. in a cron shell script):
  68. ```` bash
  69. mysql --user=cronuser --password=cronpassword -e "analyze table wbo;" pmsyncdb
  70. ````
  71. Where `cronuser` and `cronpassword` are the credentials of a MySQL user created for this task with insert and update privileges.
  72.  
  73. This doesn't take a very long time and can be performed live and on-line, so you don't have to take down the server for this maintenance.
  74.  
  75. On less regular intervals, you should take the server down for an `optimize table` session to reclaim disk space. Keep in mind that InnoDB tables don't support in-place optimization so you need enough free disk space to store a copy of the wbo data table temporarily. How often this is needed depends on the amount of users and the amount of data churn.
  76.  
  77. ## Operating environment considerations
  78.  
  79. For larger installations:
  80.  
  81. * Use an enterprise Linux OS to handle the concurrent network/IO needed, e.g. CentOS or Debian.
  82. * Running in a VPS is possible even for high-volume use, but be careful with the required amount of resources.
  83. * Preferably use a fast front-end. Pale Moon Sync uses the NginX/PHP-FPM combination for this.
  84. * Recommended choice of software: CentOS, NginX, PHP-FPM 5.6, MariaDB SQL server.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement