Reputation: 414
Here's a question I don't even know how to search for it in the web and probably it's a dumb question:
Would it be more efficient for a web server to set download requests and file streams on different ports like 21(ftp) than using default 80/443(http/https) ports? or even use another server to handle these requests so that there would be no longer heavy traffics over http/https connections.Is it even possible to do such action?
If yes, how can I set these settings on Express.js? and if not, what's the regular way of handling heavy downloads?
I know that it's possible to send a file over user's browser using response object like this:
app.get('/download', function(req, res){
res.download('image.jpg');
}
And as far as I know it uses http/https. I want to know if it's possible to set this on port 21 manually.
So there are two questions:
thanks for clearing this up
Upvotes: 0
Views: 265
Reputation: 707456
Putting downloads on a different port does not make a difference to the server efficiency or scale all by itself.
What does help is moving the download of static files out of the node.js process and into another process or, in large scale cases, onto another host. In all cases, I would not add the complication of additional processes until you have proven that you actually have an issue with scale and need to add that extra complexity. Scale bottlenecks are often not where you think they are so adding complexity to a project to improve scale without first measuring where your bottlenecks actually are is usually wasted effort.
Switching to a different port does not increase scalability all by itself. It isn't ports that have scale limits. It's processes and hosts. So, you can add another HTTP process (and stay with HTTP) to successfully add a process and increase scale.
Once you've proven you do actually have a scaling bottleneck with static downloads, here are some things you can do with your static downloads to increase download scale:
xxdomain.com
as their main host and img.xxdomain.com
as a separate host for image downloads.In general you want to avoid using ports other than 80 or 442 for web traffic because many network infrastructures (particular tightly controlled corporate environments) may not allow users to use other ports for web traffic.
Upvotes: 2