memdb.conf.js 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Copyright 2015 The MemDB Authors.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
  12. // implied. See the License for the specific language governing
  13. // permissions and limitations under the License. See the AUTHORS file
  14. // for names of contributors.
  15. 'use strict';
  16. /*
  17. * MemDB config template
  18. *
  19. * Please modify it on your needs
  20. *
  21. * This is plain javascript, you can add any js code here, just export the config
  22. *
  23. * DO NOT modify it when any memdb shard is running
  24. */
  25. module.exports = {
  26. // *** global settings for all shards ***
  27. // Global backend storage, all shards must connect to the same mongodb (or mongodb cluster)
  28. backend : {
  29. engine : 'mongodb', // should be 'mongodb'
  30. url : 'mongodb://localhost/memdb', // mongodb connect string
  31. },
  32. // Global locking redis, all shards must connect to the same redis (or redis cluster)
  33. locking : {
  34. host : '127.0.0.1',
  35. port : 6379,
  36. db : 0,
  37. },
  38. // Data replication redis, one redis instance for each shard
  39. // You can override this in shard settings to choice different slave for each shard
  40. slave : {
  41. host : '127.0.0.1',
  42. port : 6379,
  43. db : 0,
  44. },
  45. // Log settings
  46. log : {
  47. // Log file path, default ~/.memdb
  48. path : process.env.HOME + '/.memdb/log',
  49. // Log Level (one of 'ALL', 'TRACE', 'DEBUG', 'INFO', 'WARN', 'ERROR', 'FATAL', 'OFF')
  50. // Please set to WARN on production
  51. level : 'WARN',
  52. },
  53. // Promise settings
  54. promise : {
  55. // Enable long stack trace, disable it on production
  56. longStackTraces : false,
  57. },
  58. // user for memdbcluster ssh login, default current user
  59. // when start using memdbcluster, make sure you have ssh permission (without password) on all servers,
  60. // and the memdb version, install folder, config files are all the same in all servers
  61. user : process.env.USER,
  62. // Collection settings for index
  63. /* modify it on your need
  64. collections : {
  65. // Collection name
  66. player : {
  67. indexes : [
  68. {
  69. // Index keys
  70. keys : ['areaId'],
  71. // Value exclude from index. Values like '', -1 occurs too often, which can make the index too large.
  72. // 'null' or 'undefined' is ignored by default.
  73. valueIgnore : {
  74. areaId : ['', -1],
  75. },
  76. },
  77. {
  78. // Index keys (compound index)
  79. keys : ['deviceType', 'deviceId'],
  80. // Unique constraint for the index
  81. unique : true,
  82. },
  83. ]
  84. }
  85. },
  86. */
  87. // *** Shard specific settings ***
  88. // This will override global settings on specifid shard
  89. shards : {
  90. // shardId
  91. s1 : {
  92. // server IP
  93. host : '127.0.0.1',
  94. // listen port
  95. port : 31017,
  96. // bind Ip
  97. // DO NOT bind to localhost when deploy on multiple servers
  98. // make sure servers can communicate with each other
  99. bind : '0.0.0.0',
  100. // Add any shard specific settings here
  101. // slave : {
  102. // host : '127.0.0.1',
  103. // port : 6379,
  104. // db : 1,
  105. // },
  106. },
  107. // Add more shards
  108. s2 : {
  109. host : '127.0.0.1',
  110. port : 31018,
  111. },
  112. // s3 : {
  113. // host : '127.0.0.1',
  114. // port : 31019,
  115. // },
  116. // s4 : {
  117. // host : '127.0.0.1',
  118. // port : 31020,
  119. // },
  120. },
  121. // *** additional settings ***
  122. // These settings are unstable and may change in later version
  123. // Delay for flush changes to backend storage
  124. // Set it to large value to improve performance if the data delay in backend storage is not an issue.
  125. // persistentDelay : 600 * 1000, // number in ms, default 10 min. 0 indicates never
  126. // Idle time before document is removed from memory.
  127. // Larger value can improve performance but use more memory.
  128. // Set it to large value if the documents accessed via this shard is limited.
  129. // Do not access too many different documents in a short time, which may exhault memory and trigger heavy GC operation.
  130. // idleTimeout : 1800 * 1000, // number in ms, default 30 min. 0 indicates never
  131. // GC will be triggered when memory usage reach this limit
  132. // GC can be very heavy, please adjust idleTimeout to avoid GC.
  133. // memoryLimit : 1024, // number in MB, default 1024
  134. // Disable redis replica, DO NOT turn on this in production.
  135. // disableSlave : false, // default false
  136. // Slow query time
  137. // slowQuery : 2000, // number in ms. default 2000
  138. // Turn on heapdump module (https://www.npmjs.com/package/heapdump)
  139. // heapdump : false, // default false
  140. };