3

I'm writing a web app that is basically facebook events, but more impromptu and real time. A user can create an event, and other online users in the area (30 mile radius) should immediately see the event. Users can sign up for events, and the host should see the invites. The host can cancel the event, and all participants should receive notice. No long polling or refreshing is needed, and i'll most likely be using websockets (socket.io)

This concept is simple to describe, but i've gotten a headache just thinking how exactly this can be implemented. Especially if a user has multiple sessions..

Redis has captured my attention recently. Can i receive suggestions on my implementation plan, to make sure i'm not going down some crazy path?

  1. I keep track of logged in users locations in Redis.
  2. User creates event and I store it in Redis.
  3. I find all users that are in the 30 mile radius of event, and notify them thru socket.io
  4. The host and users who sign up for event are entered into Redis pub/sub for any kind of notifications.
  5. Once event is over, i remove event from Redis and store in MySQL

Is my implementation doable? Does it make sense to use Redis here?

3

Cache can be used and will help here as many clients for events which will rarely change. Even if they change:

  1. updating a key, or
  2. deleting and adding it back lazily, works fine.

    For exactly how you should do it - experiment. Plunge in with the only caveat : you will learn and change. Embrace that idea and run with it. I have seen code that stores same event (not of facebook but other domain's) twice - in a list and with a different key for single events... just saying depends on your use case and how much memory you have.

I would not worry about memory now. Just solve your problems and write jmeter type tests to see how well its working.

Later you can optimize and/or get more server space.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.