title: Spring boot - How to Improve api response time for Application with monthly data refresh
body: <p>We are using spring boot <code>1.5.10</code> Release version along with mongodbrepository.</p>
  <p>We have huge data so we are loading  static data(select * from table) on server startup using postconstruct.</p>
  <p>Api response size is Approx 25MB we are compressing it using gzip so size becomes 5MB.</p>
  <p>We have multiple services, every service  includes <code>@PostConstruct</code> to load (select * from table)frequently used data to prepare maps to improve performance.</p>
  <p>We are preparing map&lt;id, custom Obj&gt; from findall db query in each service
  1 service for reference..</p>
  <p>@PostCounstruct
  Init(){
  List list = xyzRepository.findAll();
  Map&lt;String, MyObj&gt; map = new HashMap():
  for(MyObj Obj : list){
  map.put(obj.id, Obj)
  }
  }</p>
  <p>User will get fast response from map when  findById / findAll / findByList(List employees&gt; emps) called</p>
  <p>Every month our  db gets refreshed/updated. Once we refreshed db we are restarting spring boot application.</p>
  <p>Problem which we are facing if there is any db refresh happened ( due to some issue/delay) within month in database, we need to restart server to get correct data instead of stale data.</p>
  <p>We tried <code>@Cacheable</code> in every service but 1st db hit taking too much time.( As we are doing select * from table).</p>
  <p>We made parallel ajax call to get data.
  Application dashboard need to plot data which is approx 30MB (gzip 5mb) which is pain..</p>
  <p>Approx 2000 users for application
  20 services..
  Each service calling  to get data ( some are getting static data from map which is initialised in postcounstruct)</p>
  <p>Currently We are restarting server monthly when db refresh happened.</p>
  <p>How we can get latest data without server restart when there is unexpected db refresh?</p>
  <p>---------[Edit-1]-----</p>
  <p>Upvoted answer suggest that populate new/update data in every map present in every service.</p>
  <p>1.Application startup time will be high as map will be populated from database.</p>
  <p>2.Overhead to populate/maintain data in some time interval(nightly/alternate day/Weekly) in Java maps.</p>
  <p>What if more data will increase in each collection/table &amp; every month.</p>
  <p>Need expert review on upvoted answer.</p>
  <hr />
  <p>Thanks for reading question </p>