• Post Reply Bookmark Topic Watch Topic
  • New Topic

Improving performance of a REST Webservice

 
Vivek K Singh
Ranch Hand
Posts: 85
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have a RESTFul webservice that goes to the database to fetch some data, The data is very static in nature and changes like once a month or so.

Still to fetch the data from DB it takes the service about 300ms, I was wondering is thare any way in which I can cache the data on server and make the service fetch it from there so that the time spent blocking on DB and IO is reduced.

And also is there any way in which the chache can be refreshed when new data is added ?

Thanks,
Vivek
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sure you can use a cache; some popular Java caching libraries are listed in http://faq.javaranch.com/java/CachingStrategies.

You'll need to add the logic to update the cache yourself, though - no way to do it automatically.
 
Tim Holloway
Bartender
Posts: 18417
58
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ORMs such as Hibernate are good for this. They cache transparently and you can also plug in enhanced caching components if you need support for such things as external database updates that would invalidate what's in cache.
 
Vivek K Singh
Ranch Hand
Posts: 85
Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tim and Ulf. While looking online memcached came up, need to see if it is too much of an overkill for the problem else its going to be hibernate cache.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!