close
  • Mo chevron_right

    Movim just flattened the (connections) curve !

    Timothée Jaussoin · pubsub.movim.eu / Movim · Wednesday, 21 October - 07:37 edit · 1 minute

A few days ago I discovered that the #Eloquent database library (the one that Movim is using for a few years now) had some events that could be caught by an event listener.

With this simple mechanism #Movim could be aware of when exactly a #SQL request is done during the execution time.

The Movim #architecture is based on several processes that talk to each others, and each connected session (each user connected to a specific XMPP account) is having its own sub-process. The main issue with this architecture is that all those processes relies on a common database (PostgreSQL or MySQL) and each process open an unique connection to the database. See How's Movim made? Part I - The Architecture to know more about this architecture.

When you start to have a lot of users connected on the same instance, this is opening lots of connections to the database. This is creating a congestion and can slow down the general performances.

This simple commit ask Eloquent to close the connection after a few seconds of inactivity. Eloquent is reconnecting automatically if a new SQL request is made after the disconnection. This allows to free-up the socket resources once "we don't really need it anymore".

And here is the result once this commit deployed on nl.movim.eu

The PostgreSQL connections curve

  • favorite

    5 Like

    debacle , eyome , U , arie , jkrosado