0

I'm currently managing PHP "events" for in a single instance. This is working well and is correctly implemented in my system using something similar to Laravel's events provider.

My question now concerns a system where I need to dispatch events across different instances/users.

For example, I have an account composed of multiple users. Each user is caching the account settings in session after the initial loading of the application. Now, if a user is doing a modification to the account settings, I'd like to send an event to my other users so they update there settings.

For the time being, I'm thinking about these solutions:

  1. Storing the events in a database table, with each users regularly checking the values, but this will require additional SQL load and would make the caching system obsolete.
  2. Another solution would be to store a flag using REDIS. Each users can regularly check the value of the flag and reload the settings is required. It's similar to the SQL solutions above but will be much more efficient with REDIS. However the implementation would be more complexe, and it might be custom built for this specific event.
  3. I also started to look at ways of sharing data between PHP instances and found this question which is suggesting the usage of shared memory. I'm not very familiar with this concept and I'm still looking at it, but I suppose that it may be possible to build a cross instance event system using it.
  4. Using memcached server in PHP. I'm not familiar with that and still evaluating the possibility of building an event dispatcher system around it.
  5. Using a message queue server. Still evaluating the possibility and also checking is existing event based system in PHP are built with it.

Is there any other solutions I could use to dispatch such events between instances?

Edit: Proposition 3 has been rejected has shared memory is done in the same server, I'm working with server clustering for the application side.

maxime_039
  • 464
  • 8
  • 14
  • You could store a Hash in the Database or in a File and put the Hash in the Session too. If the Hashes are different, you regenerate the session with the Settings from the database. – Bernhard Jun 21 '17 at 09:08
  • I'm in a clustering application type with multiple servers handling the application side, I'd prefer avoid using files therefore. Using a hash in the database to identify the configuration version is a good idea, but would require regular SQL calls. In which case using REDIS for this purpose (solution 2) seems the most adequate. – maxime_039 Jun 21 '17 at 09:40

0 Answers0