Nginx reverse proxy, load balancing, and nginx reverse load1What is reverse proxy and reverse proxy?
1.1
Forward proxy
1.2
Reverse Proxy
1.2
Use
Nginx implements reverse proxy
Nginx only forwards requests. There are multiple http servers in the background to provide services. The nginx function is to forward requests to the backend servers and decide who to forward the requests.
1.2.1
Install
balancing requirements.software Load Balancing solution is to install one or more additional software on one or more servers corresponding operating system to achieve load balancing, such as DNS load BALANCE,
are servers A, B, C in the cluster, they are non-impact, mutual irrelevant, any one machine down, will not affect the operation of other machines, when the user to a request, The algorithm of the load balancer decides which machine to handle, if your algorithm uses the round algorithm, has the user A, B, C, then respectively by Server A, B, c to handle;2.1 DNS-based load balancingLoad
command: nginx-t
Of course Nginx load Balancing function is also very strong, and it is generally as a seven-tier load balancing (Application protocol layer). Here is a description of the four common settings that are supported by its upstream:
Code highlighting produced by Actipro CodeHighlighter (freeware)
, because the consumption of system resources varies greatly by different applications, the number of connections cannot reflect the actual application load, therefore, when a heavy web server is used as a cluster node service (such as an Apache server), the algorithm will have a discount on the load balancing effect.
algorithm is applicable to TCP connections. However, because the consumption of system resources varies greatly by different applications, the number of connections cannot reflect the actual application load, therefore, when a heavy Web server is used as a cluster node service (such as an Apache server), the algorithm will have a discount on the load
Make a demo and record it. 1. Environment Preparation
Required Software: Jdk/jre Apache httpd2.4 (with 2.2 have a lot of different points) Tomcat8 several
Tips
Tomcat and Apache httpd just right I have a blog to introduce how to install;
Installing, configuring, and adding services to Apache in Linux
Configure load balancing based on MOD_JKMOD_JK Articles1, in order to avoid users directly access to the back-end Tomcat instance, affect the effect of load balancing, it is recommended to disable the http/1.1 connector on each instance of
ajp://127.0.0.1:93009 loadfactor=1 route=jvm3# The parameter "Loadfactor" indicates the backend server load to the weight of the request sent by Apache ,⑤ Modify the conf/extra/httpd-vhosts.conf file. comment out all the dummy-host, add the following contentServerAdmin localhostServerName localhostServeralias localhostProxypass/balancer://cluster/stickysession=jsessionid Nofailover=onproxypassreverse/balan
the same source address to the same server node, this allows transactions based on high-level sessions to run in an appropriate manner. The hash Scheduling Algorithm Based on the target address can be used in the Web Cache cluster. All access requests directed to the same target site are sent to the same Cache service node by the Load balancer, to avoid the Cache update problem caused by missing pages.3.3 least connection methodIn the least connectio
First, the simple introduction of load balancingLoad balancing, also known as load sharing, refers to load balancing by dynamically adjusting the load on the system, and performing the load
acceleration mode can obviously increase the access speed of static Web pages. Therefore, you can also consider using this technology to allow the proxy server to evenly forward requests to one of multiple internal Web servers, so as to achieve load balancing. This proxy method is different from the common proxy method. The standard proxy method is that the customer uses the proxy to access multiple extern
module and I
./configure–without-http_rewrite_module
Then you can make,make install.
Once installed, create a new profile, copy the contents of the configuration file, and, of course, modify your IP, save it for example load_balance.conf and start:
/usr/local/nginx/sbin/nginx-c load_balence.conf
Because the author of Nginx is Russian, so the English document is not so perfect, for me, the biggest advantage of nginx or simple configuration, powerful. I used to be a
rich set of features for DNS integration that has become increasingly popular. Other popular options are the use of distributed and replicable Key-value storage, such as ETCD in which services can register themselves. Apache Zookeeper will also be aware of the need for such a group of people.
In this article, we mainly deal with some of the mechanisms provided by Docker swarm (Docker in swarm mode) and demonstrate the service abstraction we explored
concurrency has been difficult, hardware load balancing can support
(3) Stability: Commercial hardware load balancing, after a good rigorous testing, from a large-scale use, in the stability of high;
(4) Security Protection: Hardware equalization equipment In addition to load
downloading, place these library files in the Tomcat\lib directory.(all jar packages are included in the attachment)3.2.2 Configuring memcached for TomcatConfiguration file directory: Tomcat\conf\context.xmlOpen the configuration file and add the following to the Memcachednodes= "n1:192.168.10.222:12000"#ip为mencached服务器的ipSticky= "false"Requesturiignorepattern= ". *\. (png|gif|jpg|css|js|ico|jpeg) $ "Sessi
/images.confserver { listen 8080; server_name nginx.bgx.com; location / { root /code; index index.html; }}2.Nginx Load BalancingWebServer, direct user-oriented, often to be hosted 大量并发请求 , a single server 难以负荷 , I use a number of servers, the WEB front- 集群 End use Nginx``负载均衡 , will be requested 分散 to hit our back-end server cluster, implementation 负载的分发 . Then it will greatly improve the system吞吐率、请求性能、高容灾2.1Nginx
Comparison of haproxy lvs nginx Load Balancing
For the software that implements load balancing, let's take a look at it in detail. In terms of performance and stability, LVS is the best, basically reaching 60% of the performance of F5 hardware equipment, and other 10% are a little difficult.
However, the configuration
If you do not know how to install nginx in Linux, refer to the previous article.
The configuration of nginx Server Load balancer is much simpler than that of Apache. Using nginx for Server Load balancer will not describe the configuration of the Tomcat cluster. If you do not understand the configuration of the
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.