简体   繁体   中英

Static resources (images) Tomcat or Nginx server

Give me the right way. I have nginx server (list 80port) which proxy to tomcat server (for ex 8080port). I need to get static images in my spring app. I got something like this: 1) map images on tomcat server (aliease) or Context docBase 2) map static on nginx server 3) create another sub domain for ex images.mysite.com and work with him.

And also what will be better?

Performance:

Nginx is a great webserver and at the moment is the best when talking about serving static content. You can referr to benchmarks available online, or benchmark it yourself.

Subdomain/Separate domain for static content:

By using sub/separation for static content, you will eliminate cookies on static content, reduce http request/response size and will have better performance.

You will also increase the number of parallel downloads that the browser can perform. This will reduce your page load time.

This will increase your costs if you have ssl enabled, you need a certificate for your sub/separate domain too.

There is no universal right way.

If you have a low traffic site: Use what you can set up quickest. Don't worry, if you are running into performance problems, they won't be due to this decision but due to other aspects of your solution.

If you have a high traffic site: Start with the easiest setup (same as before). Then measure where your performance problems are. Again, most likely they won't be due to the delivery of static content, but whatever your biggest performance problem is: Fix it, rinse, repeat. If static content delivery makes up for an improvement of 0.5% of performance, while another factor makes up 20%, guess where you should invest your time (hint: it's not static content delivery)

In this regards I'm totally with Klaus Groenbaek's comment: Building a complex system that's harder to maintain without having some justification (measurements) showing the advantage of the complexity is preposterous.

Unless you identify an actual performance bottleneck in your own system, optimize for maintainability, build the simplest possible system.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM