wittythotha
wittythotha

Reputation: 4136

using php to monitor mysql changes **WITHOUT** polling

I have seen many questions similar to the one I asked. A few of them said that its ok to poll, and that doesn't affect the database performance significantly, and some are still unanswered. What I want to know is this :

Thanks & Regards, Thothathri Srinivasan

Upvotes: 1

Views: 5656

Answers (4)

Alfred
Alfred

Reputation: 61793

Redis PubSub

I hoped triggers could help you out, but after a little examination I (highly) have my doubts.

You could achieve your goal using Redis pubsub. Redis is an extremely fast data structure server. Publish the database changes to a channel and let the interested clients detect the changes by subscribing to that same channel(in real-time).

Downloading/Installing Redis is really easy and as extra bonus you will also "get an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets."

Installing it is probably the best way, but if you can't, you could use the free http://redistogo.com plan to talk the Redis server with the limitation that you will only get 5MB to store your data and that it will not be persisted to disc.

Upvotes: 3

hetaoblog
hetaoblog

Reputation: 2030

I think Q4M is exactly what you want http://q4m.github.com/tutorial.html

Upvotes: 0

Joshua Martell
Joshua Martell

Reputation: 7212

I like Alfred's pubsub idea. I would think about the database as a subscriber to the insert events, not as the canonical version. Maybe this isn't possible with your existing codebase. You might also be able to monitor the binary logs on the database server to watch changes come in and push this information to the subscribers.

Upvotes: 0

Naftali
Naftali

Reputation: 146350

You can use a server push with an implementation like websockets or comet.

Upvotes: 0

Related Questions