I am trying to develop a data streaming API with the same functionality as Twitter’s streaming API (https://dev.twitter.com/streaming/reference/post/statuses/filter), namely a data stream with filtering capabilities. I am generating a lot of data and want to serve it to clients.
I understand how to make an app that serves the all clients the same data. That’s relatively easy. The difficulty I’m having comes from allowing clients to specify data filters and serving unique data to each client.
My thoughts:
First I thought to open a streaming http requests (like Twitter). I could create an endpoint that accepts GET requests with parameters (e.g. https://stream.example.com/v1/filter.json?track=twitter). According to this answer Streaming API vs Rest API?, this doesn’t scale easily and requires a lot of resources.
Then I thought to use websockets and let the client supply a filter message (e.g. locations=-122.75,36.8,-121.75,37.8). However, I can’t find a good example of a WS server dishing out unique data to each client. What would this class look like if it inherited tornado.websocket.WebSocketHandler or similar implementation?
I also considered pushing the data to a messaging service (RabbitMQ ) or database (Redis) and subscribing clients as they connect to their unique channel. (I think like this question Any ideas how to create parameterised streaming api?). I don’t know of an efficient way to create the unique channels. This also seems overly complicated.
I would prefer to do this in Python but I would also consider using Ruby and JS implementations.