0

Need a suggestion from you guys.

I am using a CI application and when I do Load test application with 100 users each time it opens a new connection and after that when I see cloud monitoring it shows 100 open connection and utilization up to 80%.

How can I reduce that?

Thanks

Mickaël Leger
  • 3,426
  • 2
  • 17
  • 36
Ishan Shah
  • 1,665
  • 2
  • 20
  • 42
  • Each user connected to your app/website counts as a new connection. Does your host limit the amount of open connections you can have? – Adam Aug 07 '18 at 12:56
  • A persistent connection couldn't do the job? See [this answer](https://stackoverflow.com/a/3332106/4932315) about pro/cons of a persistent connection. Also, be sure to close your DB connection as soon as you no longer need it, to avoid keeping a connection open. – Anthony Aug 07 '18 at 13:04
  • @Adam No, my server has max no of user connect to database. i just want to know that in one db connction can use by all other users in our site? – Ishan Shah Aug 08 '18 at 12:26
  • @AnthonyB No, each user can open a new persist connction but i want to use one persist connction to all users. how its possible? – Ishan Shah Aug 08 '18 at 12:27
  • I'm not sure if it's a good idea to use only one connection for all of your users, they'll have to wait a long time before their query being handled. You could use an object that manages a queue to give a connection. Doing so, a user asks for a connection to the object, and if there is an available connection it gets it, otherwise it waits a bit. – Anthony Aug 08 '18 at 12:42

1 Answers1

0
  1. Open a db connection
  2. Save the db connection object to a file
  3. For every use instance, load the connection object from file
  • Can you clarify how to do that? – Nico Haase Aug 09 '18 at 10:48
  • No because i've never done it. Its super impractical. It keeps query data and will bloat your system. If you really want to do it, trace where database.php is used in the system folder of CI 3. Individual connections are better because as soon as the page loads, connection is closed and memory is freed. If your load is at 80% for 100 concurrent users, you want to optimize your queries or increase your system resources. – Don Bhrayan Singh Aug 09 '18 at 10:59
  • So, you posted an answer without any code and you state that the answer is not good - then what's the point in posting this answer? – Nico Haase Aug 09 '18 at 11:03