Hi,

On Wed, Apr 7, 2010 at 2:39 PM, Jay Paroline <[email protected]> wrote:
> Ok, I think I wasn't clear enough in my question, so I wrote a simple
> example.
>
> <?php
>
> set_time_limit(0);
> $m = new Memcached('pool');
> $m->addServer('172.16.0.64', 11211);
> $m->add('monkeys', '5');
> while(1){
>    $m->get('monkeys');
>    sleep(5);
> }
>
> ?>
You have the persistent handler per process.
It is how it supposed to work, unless you want to
share a class instance among different php process's.
(I would suggest looking at apc or similar solutions for what you want.)

Moving the initialization of the server into the while loop would cause
php to use the same memcached connection even if the class instance is
different.

>
> If 5 of these are running at the same time, I would *like* to have
> them all sharing the same connection. But that's not what happens:

Are you sure you want to have such a bottleneck in your deployment ?

>
> [r...@lifebook ~]# php testMemcachePool.php &
> [1] 3291
> [r...@lifebook ~]# netstat -tnap | grep 11211
> tcp        0      0 172.16.1.84:47401
> 172.16.0.64:11211           ESTABLISHED 3291/php
> [r...@lifebook ~]# php testMemcachePool.php &
> [2] 3294
> [r...@lifebook ~]# netstat -tnap | grep 11211
> tcp        0      0 172.16.1.84:47401
> 172.16.0.64:11211           ESTABLISHED 3291/php
> tcp        0      0 172.16.1.84:47402
> 172.16.0.64:11211           ESTABLISHED 3294/php
> [r...@lifebook ~]# php testMemcachePool.php &
> [3] 3297
> [r...@lifebook ~]# netstat -tnap | grep 11211
> tcp        0      0 172.16.1.84:47401
> 172.16.0.64:11211           ESTABLISHED 3291/php
> tcp        0      0 172.16.1.84:47402
> 172.16.0.64:11211           ESTABLISHED 3294/php
> tcp        0      0 172.16.1.84:47403
> 172.16.0.64:11211           ESTABLISHED 3297/php
> [r...@lifebook ~]# php testMemcachePool.php &
> [4] 3300
> [r...@lifebook ~]# netstat -tnap | grep 11211
> tcp        0      0 172.16.1.84:47404
> 172.16.0.64:11211           ESTABLISHED 3300/php
> tcp        0      0 172.16.1.84:47401
> 172.16.0.64:11211           ESTABLISHED 3291/php
> tcp        0      0 172.16.1.84:47402
> 172.16.0.64:11211           ESTABLISHED 3294/php
> tcp        0      0 172.16.1.84:47403
> 172.16.0.64:11211           ESTABLISHED 3297/php
> [r...@lifebook ~]# php testMemcachePool.php &
> [5] 3303
> [r...@lifebook ~]# netstat -tnap | grep 11211
> tcp        0      0 172.16.1.84:47404
> 172.16.0.64:11211           ESTABLISHED 3300/php
> tcp        0      0 172.16.1.84:47405
> 172.16.0.64:11211           ESTABLISHED 3303/php
> tcp        0      0 172.16.1.84:47401
> 172.16.0.64:11211           ESTABLISHED 3291/php
> tcp        0      0 172.16.1.84:47402
> 172.16.0.64:11211           ESTABLISHED 3294/php
> tcp        0      0 172.16.1.84:47403
> 172.16.0.64:11211           ESTABLISHED 3297/php
>
>
> On our production servers, we might have 200 apache processes running
> at the same time (each running PHP). We have 21 memcached buckets, so
> our worst case scenario is 4200 active connections to memcached from
> just one front end node. In reality I'm counting 2583 with a sate of
> ESTABLISHED right now with 137 httpd processes.

Does that mean all of that 200 requests , open up a connection to all 21 at the
same time? (or you mean 21 servers ?)

Regards

/tyn


-- 
To unsubscribe, reply using "remove me" as the subject.

Reply via email to