Hosi
Hosi

Reputation: 545

mysql => too many connection

I'm writing a program on Linux that needs to have lots of simultaneous connections. It's working fine for 150 connections but for more than that mysql gives this error: "Too many mysql connections"

From here, apparently this limitation can be fixed. My question is that to what number I can increase the maximum number of connections?! How much RAM for each thread or connection?

Is pthread good enough for this application?

Thanks a lot

Upvotes: 2

Views: 2837

Answers (4)

Dongfang Qu
Dongfang Qu

Reputation: 351

Usually, service mysqld restart --max-connections=500 will do the job for you.

Upvotes: 1

Ferdous Islam
Ferdous Islam

Reputation: 75

You have to set max_connections more than 151 to login with user and password of your mysql server.

set global max_connections = 15000;

Upvotes: 2

Joachim Sauer
Joachim Sauer

Reputation: 308001

If you've got a three-tier application (i.e. your application runs on some application server and users connect to it using either a browser or a dedicated client), then a connection pool might help you.

The idea is to keep a pool of open connections and only take from that pool as needed and to return the connection to the pool as quickly as possible.

This way the actual number of open connections should be much lower than the number of active sessions/users.

Upvotes: 1

Chipmunk
Chipmunk

Reputation: 348

Might connection pooling be of use? or does your application have to have 150+ connections open at the same time? I find it hard to belive that you need to have 150 concurrent connections. A bit more information on what you are trying to do would be helpful.

Upvotes: 1

Related Questions