title: ElasticSearch 100% CPU
body: <p>Create the similar <a href="https://discuss.elastic.co/t/elasticsearch-windows-service-100-cpu/101734?u=aleha84" rel="nofollow noreferrer">topic</a> for better question coverage.</p>
  
  <p>Using ElasticSearch 5.4.0 as Windows Service. Windows Server 2016 with 16 GB RAM.</p>
  
  <p>Installed via command: elasticsearch-service.bat manager</p>
  
  <p>Java options: </p>
  
  <pre><code>-Xms8g
  -Xmx8g
  -XX:+UseConcMarkSweepGC
  -XX:CMSInitiatingOccupancyFraction=75
  -XX:+UseCMSInitiatingOccupancyOnly
  -XX:+DisableExplicitGC
  -XX:+AlwaysPreTouch
  -Xss1m
  -Djava.awt.headless=true
  -Dfile.encoding=UTF-8
  -Djna.nosys=true
  -Djdk.io.permissionsUseCanonicalPath=true
  -Dio.netty.noUnsafe=true
  -Dio.netty.noKeySetOptimization=true
  -Dio.netty.recycler.maxCapacityPerThread=0
  -Dlog4j.shutdownHookEnabled=false
  -Dlog4j2.disable.jmx=true
  -Dlog4j.skipJansi=true
  -Delasticsearch
  -Des.path.home=C:\elasticsearch
  -Des.default.path.logs=C:\elasticsearch\logs
  -Des.default.path.data=C:\elasticsearch\data
  -Des.default.path.conf=C:\elasticsearch\config
  </code></pre>
  
  <p>Initial memory pool: 8192 MB</p>
  
  <p>Maximum memory pool: 8192 MB</p>
  
  <p>Thread stack size: 1024 KB.</p>
  
  <p>Filled with data after index creation with norconex crawler once. After it finished working the process is almost 100% in Task Manager all the time. It lowers sometime to 0% or 25%, but revert back to 95% after a minute. </p>
  
  <p>ElasticSearch.log file is filled with records of this type:</p>
  
  <pre><code>[2017-09-25T16:23:13,166][INFO ][o.e.m.j.JvmGcMonitorService] [Zugx4zq] [gc][9415] overhead, spent [364ms] collecting in the last [1s]
  [2017-09-25T16:23:14,534][INFO ][o.e.m.j.JvmGcMonitorService] [Zugx4zq] [gc][9416] overhead, spent [647ms] collecting in the last [1.3s]
  [2017-09-25T16:23:15,550][INFO ][o.e.m.j.JvmGcMonitorService] [Zugx4zq] [gc][9417] overhead, spent [397ms] collecting in the last [1s]
  [2017-09-25T16:23:16,708][WARN ][o.e.m.j.JvmGcMonitorService] [Zugx4zq] [gc][9418] overhead, spent [657ms] collecting in the last [1.1s]
  [2017-09-25T16:23:17,745][INFO ][o.e.m.j.JvmGcMonitorService] [Zugx4zq] [gc][9419] overhead, spent [494ms] collecting in the last [1s]
  </code></pre>
  
  <p>Requests executing too long or failed with exeption:</p>
  
  <pre><code>org.elasticsearch.transport.RemoteTransportException: [Zugx4zq][127.0.0.1:9300][indices:data/read/search[phase/query]]
  Caused by: org.elasticsearch.common.util.concurrent.EsRejectedExecutionException: rejected execution of org.elasticsearch.transport.TransportService$7@25194f on EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@48fa409f[Running, pool size = 7, active threads = 7, queued tasks = 1000, completed tasks = 93134]]
  
  org.elasticsearch.transport.RemoteTransportException: [Zugx4zq][127.0.0.1:9300][indices:data/read/search[phase/query]]
  Caused by: org.elasticsearch.common.util.concurrent.EsRejectedExecutionException: rejected execution of org.elasticsearch.transport.TransportService$7@34fbd561 on EsThreadPoolExecutor[search, queue capacity = 1000, org.elasticsearch.common.util.concurrent.EsThreadPoolExecutor@48fa409f[Running, pool size = 7, active threads = 7, queued tasks = 1000, completed tasks = 118501]]
  </code></pre>
  
  <p>I dont't understand who generating this kind of loading on this service. Where are all this tasks from (queued tasks = 1000)? How to monitor service loading? What kind of service fine tuning i missed? I'm not a DevOps or professional System Administrator, i'm a .net programmer, so all this java apps is a dark wood for me. </p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Server RAM increased to 32GB. Heap size changed to 24 GB. CPU utilization lowered to minimal values. It is weird, that index with 17k documents and with size 1.1 GB is not enought heap size 8 GB.</p>