JayThomason / Tutti

Tutti is a shared music application for the car being made in conjunction with Audi.
3 stars 1 forks source link

Remove jams from server #168

Closed JayThomason closed 10 years ago

JayThomason commented 10 years ago

Right now jams persist on the server until I manually remove them using the psql console. This is unacceptable.

We should implement a method of removing jams from the server. I am going to start with a basic solution: adding a /keepAlive endpoint to the server API which updates a timestamp in the database, a background thread on the master phone that hits the /keepAlive endpoint, and a timed job on the server that deletes all jams in the database with a timestamp which has not been updated in some amount of time.

JayThomason commented 10 years ago

@hwray if you can think of a better way to do this then let me know. This method won't scale all that well because every jam that is running is going to constantly be making requests to our server(s)...

JayThomason commented 10 years ago

Added KeepAliveThread on the master phone that sends a keep alive request once every 10 seconds: https://github.com/JayThomason/Tutti/commit/bfad9707e134d6614f0f4ee58f10264eaad48fdd

hwray commented 10 years ago

This seems like a good way to do things. 10 seconds seems like a bit of overkill to me, I would think once per minute or something would be fine. Let's keep in mind that the worst case scenario for slow updating of the server is: the user thinks a Jam that has been removed still exists, clicks on it to join, and never receives a response. Not too catastrophic.

We could also set up a cron job on the server that pings each jam in the table once every so often and removes those that don't respond.

JayThomason commented 10 years ago

The question is what do we want our resolution to be for jam removal? If we want jams to be removed within 1 minute of when they are finished then we remove then we should send a keepAlive request less than once per minute.

I'll switch to once per minute and I'll have the check on the server run every two minutes.

hwray commented 10 years ago

I understand that. My argument is that our resolution really doesn't matter, because nothing noticeably bad will happen if the user attempts to join a non-existent Jam.

JayThomason commented 10 years ago

It's definitely not a serious problem if we don't remove the jams very often and I recognize that nothing bad happens when you try to join a bad jam. I was more thinking about this from a UX perspective. By leaving in finished jams we are potentially making the user sort through potentially non-existent jams.

It's just another downside to having to use a server to do this IMO.

JayThomason commented 10 years ago

implemented the /keepAlive endpoint on the server and a function to delete jams every 2 minutes if the /keepAlive endpoint for that jam hasn't been hit in the last 2 minutes: https://github.com/JayThomason/tutti-server