Turn: Use Nginx to build a simple image server under Linux

Source: Internet
Author: User
Tags tomcat server

Recently, people often ask how to upload pictures, what are the options to do better, but also to see the practice of uploading pictures, but are not the best, today, here is a brief description of the Nginx implementation of uploading pictures and pictures of the general idea of the server.

If it is a personal project or small Business Project, only 10 orwith people use small projects, you can use the following scenarios:

The user accesses the system, uses the upload picture function, then the picture uploads to your current project to be on the Tomcat server, under the/image, the upload succeeds after the user can directly access

Http://ip:port/project/images/xxx.jpg

This is not a problem when the user is low

When your business has grown, the volume of business has increased, the use of the project began to grow up, and found that the system is slowing down, then you consider the cluster, right?

So good, assuming you add a TOMCATB, performance improved a bit, the picture also successfully uploaded, do a load balancer, assuming that the picture uploaded tomcata (the user is not aware of)

When the second visit (regardless of the session sticky not sticky problem, assuming that it is shared), the user access to the TOMCATB, the picture is not, is a big fork,

Oh, my God! What's the matter, obviously just uploaded pictures did not have,

Just refresh it, hey! You got it again? What's the situation?

Backstage know what, but users do not know AH!!!

So the solution is this, tomcata and B upload to the image server, this user requests only access to the image server path, so there is no problem

Some people will ask the image server with what to build it?

Tomcat? Yes, but Tomcat is the main processing jsp better, picture files are static resources, processing performance general-like

Apache? Yes, pure C language development, no problem, but not good enough

Nginx? By the right, this is a relatively popular reverse proxy server, I have a brief introduction to the previous article (http://www.cnblogs.com/leechenxiang/p/5327086.html)

The theory of single-machine concurrent can reach 50,000, very much, the actual test is about 2w

Install the following plan to do, then the picture server is not a problem,

Of course, after uploading the image, you need to save the path address of the image to the database.

I have seen a set of e-commerce system picture upload is the adoption scheme is similar to 1, so no problem,

But, the picture actually uploaded to his meow MySQL some field of a table, your sister Ah, my God!

How can you do this, not to mention that the database does not have a partitioned partition index, OK, this is also a spit point of mine, who told me I have been involved in it?

Well, that's a lot of theory, and the next article will tell you exactly how to do it.

Nginx Create virtual static server http://www.linuxidc.com/Linux/2016-04/130373.htm

For more nginx related tutorials, see the following :

CentOS 6.2 Combat Deployment nginx+mysql+php http://www.linuxidc.com/Linux/2013-09/90020.htm

Using Nginx to build a Web server http://www.linuxidc.com/Linux/2013-09/89768.htm

Build linux6.3+nginx1.2+php5+mysql5.5-based Web server whole process http://www.linuxidc.com/Linux/2013-09/89692.htm

CentOS 6.3 under Nginx performance tuning http://www.linuxidc.com/Linux/2013-09/89656.htm

CentOS 6.3 Under the configuration Nginx load ngx_pagespeed module http://www.linuxidc.com/Linux/2013-09/89657.htm

CentOS 6.4 Installation Configuration nginx+pcre+php-fpm http://www.linuxidc.com/Linux/2013-08/88984.htm

Nginx installation Configuration Use detailed note http://www.linuxidc.com/Linux/2014-07/104499.htm

Nginx log filtering using ngx_log_if does not log specific logs http://www.linuxidc.com/Linux/2014-07/104686.htm

Turn: Use Nginx to build a simple image server under Linux

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.