Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to implement concurrent access Control in Web Application Server

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "Web application server how to achieve concurrent access control", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "Web application server how to achieve concurrent access control" this article.

The front-end load is one, and the function is that the client initiates a http request to the front-end load balancer server, and then the load layer forwards each message to each web server in the back segment intact according to the polling algorithm defined by web server. The pressure is not great, because it has been transferred to the backend.

However, there is a problem. When the client initiates a http request to the front-end load layer, the number of requests will reach hundreds of thousands within a minute (the project business needs, the client needs to synchronize the amount and other data to each project server), basically the synchronization requests made by the client to the server, as well as other access requests to the web site. Then there may be some synchronization requests that do not have to or need to be made so frequently or that there is no need to synchronize data at all during this time. In view of this, I want to see if I can do a concurrency control in the front-end load layer, and do an operation on the passed client IP. When the number of IP requests is greater than a certain value set internally, let it refuse access to the server, so that the server will be more efficient in processing messages. After thinking about it, it should be possible to achieve it, so I have the following script. Write it down for your reference.

#! / bin/bash#Author:You Names#Contact Mail:455436588@qq.com#Version:3.0#Company:COMPANY#Create time:2019-07-17 17:31:58#Description:Nginx server concurrency restrictionsMax=100000CFS=/usr/local/nginx/conf/nginx.confLOGS=/usr/local/nginx/logs/access.log# executes loop body # to filter out the'$remote_addr' address defined in the access.log log. Cat $LOGS | awk'{print $2}'| sort-n | uniq-c | sort-rn | head-n 10 | while read line do # defines the variable $IP, printing which IP; IP= `echo "$line" | awk'{print $2}'`# defines the variable $Count and prints out the number of times this IP appears; Count= `echo "$line" | awk'{print $1}'` # defines the variable $Docs, with a value of nginx's configuration file Docs=$ {cat $CFS} # defines the variable $CFG. See if there is this IP; CFG= `echo "$Docs" | grep "${IP}" `# in the configuration file. If the value of $Count is greater than the value of $Max and is empty in $CFG, perform replacement and write to the specified location of $Docs to do deny operation, reload and continue. If [[$Count-gt $Max]] & & [[$CFG = = ""]] & & [[$IP! = "IP ADDRESS"]] & & [[$IP! = "IP ADDRESS"]] then sed-I'/ location\ / {/ a\ deny'${IP}';'$CFS sed-I'/ location\ / pads {/ a\ deny'${IP}' '$CFS sed-I' / location\ ~\ *\\ .ios\ ${/ a\ deny'${IP}';'$CFS sed-I'/ location\ ~\ *\\ .Android\ *\ ${/ a\ deny'${IP}';'$CFS / usr/local/nginx/sbin/nginx-t & & / usr/local/nginx/sbin/nginx-s reload & echo "success!" Else continue fidone above is all the content of the article "how to implement concurrency access control in Web application server". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report