Too many connections error memcached

Matt Bartolome mattxbart at gmail.com
Tue Sep 18 18:02:05 UTC 2007


On 9/17/07, Brett Hoerner <bretthoerner at bretthoerner.com> wrote:
> On Sep 17, 2007, at Sep17, 5:57:05PM, Matt Bartolome wrote:
> > This would be 50 (max clients) X 150 (requests per child) = 7500
> > max connections
> >
> > At this point I'm guessing we should probably add another front end
> > apache server.
>
> Well, the client should be properly closing the connections to begin
> with.  You should really only have 50 max connections at a time (1
> per client, which is then closed when finished).
>
> As Jeremy said,
>
> >> You're likely putting a bandaid on a different problem.  You'll run
> >> into this problem again if you add more MaxChildren or more apache
> >> front ends.

Definitely something I want to avoid. Thanks for pushing me towards a real fix!

> >>
> >> Verify what python memcached client you're using and which version it
> >> is.  Verify what version of memcached you're running.   Come
> >> back.  :)

Ok, I'm using python-memcached 1.39, memcached 1.2.2,  and apache
2.0.55-4ubuntu2.1

Here is the section of my apache2.conf that has all the goodies:

# Timeout: The number of seconds before receives and sends time out.

Timeout 300

# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.

KeepAlive Off

# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.

MaxKeepAliveRequests 100

# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.

KeepAliveTimeout 15

##
## Server-Pool Size Regulation (MPM specific)
##

# prefork MPM
# StartServers ......... number of server processes to start
# MinSpareServers ...... minimum number of server processes which are kept spare
# MaxSpareServers ...... maximum number of server processes which are kept spare
# MaxClients ........... maximum number of server processes allowed to start
# MaxRequestsPerChild .. maximum number of requests a server process serves
<IfModule prefork.c>
ServerLimit           50
StartServers          20
MinSpareServers       10
MaxSpareServers       25
MaxClients            50
MaxRequestsPerChild  300
</IfModule>

# pthread MPM
# StartServers ......... initial  number of server processes to start
# MaxClients ........... maximum  number of server processes allowed to start
# MinSpareThreads ...... minimum  number of worker threads which are kept spare
# MaxSpareThreads ...... maximum  number of worker threads which are kept spare
# ThreadsPerChild ...... constant number of worker threads in each
server process
# MaxRequestsPerChild .. maximum  number of requests a server process serves
<IfModule worker.c>
StartServers         2
MaxClients         150
MinSpareThreads     25
MaxSpareThreads     75
ThreadsPerChild     25
MaxRequestsPerChild  0
</IfModule>

# perchild MPM
# NumServers ........... constant number of server processes
# StartThreads ......... initial  number of worker threads in each
server process
# MinSpareThreads ...... minimum  number of worker threads which are kept spare
# MaxSpareThreads ...... maximum  number of worker threads which are kept spare
# MaxThreadsPerChild ... maximum  number of worker threads in each
server process
# MaxRequestsPerChild .. maximum  number of connections per server
process (then it dies)
<IfModule perchild.c>
NumServers           5
StartThreads         5
MinSpareThreads      5
MaxSpareThreads     10
MaxThreadsPerChild  20
MaxRequestsPerChild  0
AcceptMutex fcntl
</IfModule>


>
> Regards,
> Brett
>

Thanks guys!
Matt


More information about the memcached mailing list