Restlet streaming data

后端 未结 1 643
走了就别回头了
走了就别回头了 2021-02-03 10:57

I have this task that I\'m undertaking where I would be reading data from a device and make it available over a web service. The data is read 4 times a second. I want the web cl

相关标签:
1条回答
  • 2021-02-03 11:33

    To achieve what you are trying to do, I'd use the WriterRepresentation (but see my answer to your other question), but I'm quite sure that you are going in the wrong architectural direction.

    Indeed the following image from the documentation you linked

    enter image description here

    shows how even the Twitter streaming api is not intended to be connected by users, but by background processes that download messages in a store accessible by the HTTP. Users poll only the HTTP server, that reads the messages from the store and sends the back to the clients.

    As a disconnected protocol, HTTP enable massive scalability that would not be possible otherwise. If each client establishes a persistent TCP connection backed by a dedicated server thread, you will rapidly exaust server resources! Moreover any HTTP proxy between the User Agent and the server could cause unexpected behaviours.

    Thus, if you are bound to the HTTP protocol, the User Agent should poll. You can reduce the network load with headers like Last-Modified/If-Modified-Since or Etag/If-None-Match.

    However, if you can adopt a different protocol, I strongly suggest to try a service bus over a connected TCP protocol.

    0 讨论(0)
提交回复
热议问题