title: Reducing number of Hazelcast threads
body: <p>For testing purposes, I want to run multiple instances of Hazelcast on a single node.  Hazelcast assumes that it is managing the entire node, and therefore it creates a large enough number of threads to fully (in fact, over) load all the cores.  On my 8-core Linux node, Hazelcast creates 74 threads per instance, which quickly runs up against the user thread limit.  (Yes, I know this can be changed with <code>ulimit</code>.)</p>
  
  <p>From <a href="http://docs.oracle.com/javase/7/docs/technotes/guides/management/jconsole.html" rel="nofollow noreferrer">jconsole</a> threads view:</p>
  
  <ul>
  <li>hz.hzInstance_1_dev.scheduled</li>
  <li>hz.hzInstance_1_dev.generic-operation.thread (x16)</li>
  <li>hz.hzInstance_1_dev.partition-operation.thread (x16)</li>
  <li>hz.hzInstance_1_dev.response</li>
  <li>hz.hzInstance_1_dev.event (x5)</li>
  <li>hz.hzInstance_1_dev.wait-notify</li>
  <li>hz.hzInstance_1_dev.wan (x16)</li>
  <li>hz.hzInstance_1_dev.cached.thread</li>
  <li>hz.hzInstance_1_dev.migration</li>
  <li>hz.hzInstance_1_dev.IO-thread-in (x3)</li>
  <li>hz.hzInstance_1_dev.IO-thread-out (x3)</li>
  <li>hz.hzInstance_1_dev.IO-thread-Acceptor</li>
  <li>hz.hzInstance_1_dev.cached-thread (x8)</li>
  <li>hz.hzInstance_1_dev.HealthMonitor</li>
  </ul>
  
  <p>Some of the thread counts can be reduced by setting <a href="http://docs.hazelcast.org/docs/3.7/manual/html-single/index.html#system-properties" rel="nofollow noreferrer">Hazelcast system properties</a>:</p>
  
  <ul>
  <li>generic-operation.thread = <code>hazelcast.operation.generic.thread.count</code></li>
  <li>partition-operation.thread = <code>hazelcast.operation.thread.count</code></li>
  <li>IO-thread = <code>hazelcast.io.thread.count</code></li>
  <li>event = <code>hazelcast.event.thread.count</code></li>
  </ul>
  
  <p>The default numbers of wan, generic-operation and partition-operation threads are all 2 x CPU core count.  There doesn't appear to be any way to reduce the number of wan threads.</p>
  
  <p>Is there a way to specify how many cores Hazelcast should use, rather than specifying <code>generic-operation.thread</code> and <code>partition-operation.thread</code> separately?  Setting CPU affinity doesn't work, as Hazelcast still thinks it has access to all the cores.</p>
  
  <p>Is there any way to change the number of WAN replication threads?</p>