Lets say I'm building a site similar to this or Quora (or some arbitrary blog-like site). I need a real-time component that will be using web-sockets/long-polling to notify the user of new posts, questions, etc. depending on what page the user is viewing. That real time component will essentially be the site's API implemented in something like Twisted or Java NIO, and the site's web server will be sitting in front of say Flask or Pyramid.
Should the API and webpages be served by the same component or is it best to keep them separate?
(I'm asking both logically and physically)
1 Answer 1
Logically, it doesn't matter where the service comes from. Conceptually you can think of the web pages being served as simply another service.
What does matter is that the service is built in such a way that it can be used independently of other services. In other words, it wouldn't make much sense to have a public API that only works if you must also accept the web pages it serves.
Physically, it might matter for reasons of scalability or location. Aside from that, nothing prevents you from having both a public web API and your web pages in the same application, on the same machine.
Explore related questions
See similar questions with these tags.