Aug 21
2014

Scalable php server jobs with Gearman

The load on our servers are increasing, more and more users are joining us, and they all send updates on a regular basis. On every update we need to consider if we need to raise an alarm and send an email or sms. Recently we are starting to extend this functionality with customized rules that trigges alarms dependent on the users needs.

The alarm function is not in itself a heavy job,but summing up every request its loads the server heavily.

Here is what we did to distribute the load and make it scalable with Gearman:

Install http://gearman.org/ and use workers to handle the alarms. On every request we start a gearman worker after saving the updates from the client. The worker can easily extract and analyze the submitted data, and raise any alarms, send email/sms/api alerts in the background.

In this way we can add complex functionality without any performance troubles. Needing more computing power,  we just add servers until we are happy with the distribution of load.

Here is an overview of the Gearman framework, its not limited to PHP, but can be used with C, C++, Perl, Python etc. you name it.

Gearman stack

This entry was posted in php. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *