Search code examples
symfonyeventsrabbitmqevent-dispatchingsymfony-eventdispatcher

When should I switch from Symfony EventDispatcher to RabbitMQ (any *MQ library)?


What I am currently thinking about is that on our platform, number of events generated by users encreases every day (call started, call ended, call record ready, user blocked etc), so when should be the right time to switch from Symfony EventDispatcher to something more efficient, scalable?

Correct me please if I am wrong: Symfony EventDispatcher loads every subscriber into the server RAM and holds it until the request is being processed? If yes, that means that 2 generated events will occupy 2x(sum of all subscriber classes) memory in RAM, that will lead me to increasing server RAM and that will lead me to paying more instead of using efficient methods of event processing (libs, system architecture etc).


Solution

  • IMHO main reason to switch to MQ should be high code execution time .

    If you have a lot of events (with for example operations on database) then your execution time goes up .

    Events are fired up inside request->response, and with MQ you can put it outside your application , that means that you will have better execution time , but all events operation will be working "on background" - so it won' be "real time".

    Personally i never seen high ram usage that comes directly form subscribers/listeners- even in some big projects.