First of all, I would like to tell you guys to understand my English skill even if it's miserable to read it. I'm really trying to learn English nowadays.
-
I'm currently developing a web community that might have 2k ~ 3.5k visiting users per day. and the web server is running on top of NodeJS + Express.
and I'm using a boilerplate called react-starter-kit. and this boilerplate has HTTP, API server at once on a single NodeJS server application. (it provides server-side rendering as well)
while I was working for that project, a thought about performance suddenly came up in my head:
If this server serves both API and HTTP, Isn't it too heavy load on a single nodejs application? and when I rewrite the API part of server, It eventually affects whole web server..
so I just separated API server from HTTP server, and It works great as far as I see. then I finally reached what I want to ask about.
If API server and HTTP server is separated, Isn't it taking extra time to load web page since it does SSR (server-side rendering) which means fetching data from server to server?
below scenario is what I worry about:
- a user requests a route
/me
. /me
route need to display current signed user information.- so HTTP server try to get/fetch current signed user information with authentication token (JWT) which is sent to HTTP server from client.
- now HTTP server complete to render
/me
route and send it to client.
in this scenario, HTTP server should process extra fetching logic like what I explained on 3 of above scenario flow. and since HTTP server requests to API server, I think there's some problems:
- It takes longer time to start downloading whole web page.
- API server would conflict about client information.
- It produces heavier load on the API server since both HTTP server and HTTP client requests on a API server.
I think I misunderstood benefits of separating API and HTTP server
. can someone correct my thoughts? or tell me If I'm doing well?