> All, > > I am developing a simple web app with 2 servlets - one to process read > requests from memcached and one to process write requests to > memcached. > > My question has to do with best practices on how to do this from a > servlet - since, at any given time, there may be a large pool of > running servlets.. Should each servlet *instance* initialize it's own > memclient? Or can all instances of a particular servlet share a > memclient? Even if they *could*, should they? Is the memclient > synchronized? Do I need to take care of synchronization myself? > > As you can see, I'm looking for some tips. I don't have a good feel > for what is best. Finally, my application will only be adding things > to memcached and reading items from memcached - it will not be > *updating* items already in memcached... > > Thanks for your help?
Are you using memcached as a cache? Or as some kind of messaging scheme? Have a look at using the spymemcached libary at http://code.google.com/p/spymemcached/ It has some very interesting optimizations http://code.google.com/p/spymemcached/wiki/Optimizations This might wiki page might answer some of your questions best. If you're using hibernate at all, you should consider using the hibernate-memcached library written on top of spymemcached... http://code.google.com/p/hibernate-memcached/ (shameless self promotion :P)
