stevenkang / spymemcached

Automatically exported from code.google.com/p/spymemcached
0 stars 0 forks source link

Multi-thread support #140

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Need an ability to get/set values of memcached servers for a web application 
where is a big number of users.

Original issue reported on code.google.com by Alexander.Petrichkovich@gmail.com on 10 Jun 2010 at 7:25

GoogleCodeExporter commented 9 years ago
What problem do you have that you believe is not served currently?  It is not 
clear from your bug.

Original comment by dsalli...@gmail.com on 10 Jun 2010 at 11:06

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've read that spymemcached is a single-threaded client, but memcahced server 
supports multiple threads. In my web application Apache Tomcat creates many 
parallel threads for each user. So, I want as fast as possible application. All 
of this threads should work in parallel don't waiting while some thread 
read/write value from/to the memcached server.

Original comment by Alexander.Petrichkovich@gmail.com on 11 Jun 2010 at 10:51

GoogleCodeExporter commented 9 years ago
Use one spymemcached client for all of your threads.  If you are able to detect 
that it is in any way a performance bottleneck, create a pool of two or three.

More threads ≠ more faster unless you're actually CPU bound and have idle 
cores to spin up.  In a typical network application, you can run a lot faster 
with fewer threads than you can with more.

Original comment by dsalli...@gmail.com on 11 Jun 2010 at 5:31

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Web application is highly loaded social network. On this time number of 
processors is 4 each with 12 cores (total number of cores is 48)... I think it 
is not right way to use few clients. What to do when number of servers will be 
1000?

Solution should be scalable.

Original comment by Alexander.Petrichkovich@gmail.com on 11 Jun 2010 at 7:14

GoogleCodeExporter commented 9 years ago
Do you have any evidence that it's not?  It sounds like you have an idea of how 
it should work and with your idea of how it should work you're deciding it 
wouldn't perform well.

Please try my idea of how it works and suggest specific things that would 
benefit you after your testing.

Original comment by dsalli...@gmail.com on 11 Jun 2010 at 9:17

GoogleCodeExporter commented 9 years ago
Hi, I've tested array of clients and according on results I can do the next 
assumptions:
1. memcached 1.4.5 supports multi-threading by default.
2. the optimal number of clients depends on number of cores.

So, YOUR solution to use a pool is simple and nice :)

Hmm, now there is a one thing what is interesting for me: in this time I don't 
know why, for example, 2 methods 'MemcachedClient.set()' can't be executed in 
the same time... Is there some 'synhrozed method' in spymemcached client or 
something else?

Original comment by Alexander.Petrichkovich@gmail.com on 14 Jun 2010 at 10:47

GoogleCodeExporter commented 9 years ago
You can call set, or get, or anything else you want from as many threads as you 
want concurrently.  The only time you should worry about pooling is when you've 
proven that that you're saturating a core with the client and have more 
processing power to spare.

Original comment by dsalli...@gmail.com on 14 Jun 2010 at 10:52