brianfoshee / aquaponics-data

0 stars 0 forks source link

Thoughts on background data insertion #31

Closed brianfoshee closed 9 years ago

brianfoshee commented 9 years ago

This definitely isn't something we'd need right now, but would be an interesting test of using concurrent communication in the server.

I've been watching some Go talks on concurrency and I think there's a way we could get a lot more performance out of the servers.

If we setup a channel to send the raw JSON from a POST into, then a request can return almost immediately. Then, we'll run an infinite loop in a goroutine that consumes data from the channel and inserts it into the database. The database INSERTS will still take as long as they usually would, but we get the benefit of being able to handle more requests because the INSERTS are being done outside of the request/response cycle. I'll work on some example code to better explain.

brianfoshee commented 9 years ago

Going to close this out until it's really necessary