在PCB行业众多系统中PCB工程系统是主要的数据生产者, 它与外部系统数据交互是最多的,经统计接口数超过100个之多;这么多接口调用与管理起来是混乱的,所以今年年初对工程集成方式改造,将原来的点对点的方式集成更改为Web中心集成方式,并业务逻辑与数据层全部转向Web中心端处理,下面看看工程集成线路改造前后集成线路图.

改造前---PCB工程系统集成线路图

改造后---PCB工程系统集成线路图

改造后优点,

1.集成管理工程系统接口内部调用与外部调用
     2.统一工程系统客户端调用参数传递
     3.统一业务逻辑与数据层
     4.统一Log 日志记录
     5.外部接口变更,可以实现客户端不用更新达到接口更新

但存在缺点,业务逻辑处理压力全部压在Web中心(其实也算不上缺点,当PCB业务量发展到一定的程度一台服务器扛不住时,基本都是采用分而治之的思想,1台服务器不行稿2台,2台不行稿3台,)

但由于统一集成接口管理,逻辑业务处理全部转向Web中心端处理,这样一来导致压力全部集中在一台Web服务器上, 目前此台服务器一直处于高位运行, 以当前的订单量还能应付,但我们搞程序的人总要有居安思危,有防患于未然的意识, 不要等到哪天服务器服务器扛不住了,再想解决办法就晚了是吧.这里就介绍使用Nginx让IIS7实现负载均衡,使用起来好简单,网上也有很多例子,这里用实际操作再记录一遍。

一.下载Nginx

官方下载 http://nginx.org/en/download.html

目前1.14.0这个版本最稳定,在64位与32位都运行了没问题.

二.解压Nginx

这是绿色软件,不需安装,解压zip后,再配置一下就能用,但不能放在中文目录下,不然运行不起来

三.配置Nginx

四.启动Nginx,并验证是否成功

五.Nginx配置负载均衡

配置代码:

#user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; upstream myserver{
server 172.18.226.184:8030 weight=2 down;
server 172.18.226.184:8031 weight=1;
server 172.18.226.184:8032 weight=2;
ip_hash;
} server {
listen 8033;
server_name myserver; #charset koi8-r; #access_log logs/host.access.log main; location / {
root html;
index index.html index.htm;
proxy_pass http://myserver;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost; # ssl_certificate cert.pem;
# ssl_certificate_key cert.key; # ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m; # ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on; # location / {
# root html;
# index index.html index.htm;
# }
#} }

请求尺寸大小可以在nginx.conf中的http中设置:

    client_max_body_size 20M;
client_body_buffer_size 256k;

六.实测网页

http://pcbren.cn:8033/

这样就可以实现对外一个网址,但对内却是多台服务器(这里用端口号区分)

六.nginx批处理管理

用于nginx管理 有nginx.bat管理更方便(来自http://leleroyn.cnblogs.com,感谢分享)

cls
@ECHO OFF
SET NGINX_PATH=D:
SET NGINX_DIR=D:\nginx-1.14.0\
color 0a
TITLE Nginx 管理程序 Power By Ants (http://leleroyn.cnblogs.com)
GOTO MENU
:MENU
CLS
ECHO.
ECHO. * * * * Nginx 管理程序 Power By Ants (http://leleroyn.cnblogs.com) * * *
ECHO. * *
ECHO. * 1 启动Nginx *
ECHO. * *
ECHO. * 2 关闭Nginx *
ECHO. * *
ECHO. * 3 重启Nginx *
ECHO. * *
ECHO. * 4 退 出 *
ECHO. * *
ECHO. * * * * * * * * * * * * * * * * * * * * * * * *
ECHO.
ECHO.请输入选择项目的序号:
set /p ID=
IF "%id%"=="1" GOTO cmd1
IF "%id%"=="2" GOTO cmd2
IF "%id%"=="3" GOTO cmd3
IF "%id%"=="4" EXIT
PAUSE
:cmd1
ECHO.
ECHO.启动Nginx......
IF NOT EXIST %NGINX_DIR%nginx.exe ECHO %NGINX_DIR%nginx.exe不存在
%NGINX_PATH%
cd %NGINX_DIR%
IF EXIST %NGINX_DIR%nginx.exe start %NGINX_DIR%nginx.exe
ECHO.OK
PAUSE
GOTO MENU
:cmd2
ECHO.
ECHO.关闭Nginx......
taskkill /F /IM nginx.exe > nul
ECHO.OK
PAUSE
GOTO MENU
:cmd3
ECHO.
ECHO.关闭Nginx......
taskkill /F /IM nginx.exe > nul
ECHO.OK
GOTO cmd1
GOTO MENU

七.更多Nginx配置请链接,这里整理如下:

Nginx负载均衡简单配置

4 种负载均衡算法       

nginx反向代理proxy_pass配置URI引起的思考

八.PCB工程OCR文字识别工具改造

另一篇文章PCB 内网实现《OCR文字识别》实现逻辑 采用的2套 WCF接口嵌套调用实现内外网访问的,回想起这方法好笨呀,有了这么好的工具可以进行改造了,在内网Web服务器中直接用Nginx进行反向代理就好了。

最新文章

  1. Redis 缓存过期(maxmemory) 配置/算法 详解
  2. Redis 缓存 + Spring 的集成示例
  3. iOS崩溃日志记录工具--CrashlyTics
  4. oc调用rest api
  5. linux ssh rsa免输入密码
  6. 【NOI2004】郁闷的出纳员
  7. jQuery.validationEngine前端验证
  8. vim 多行同时输入,且输入数值递增
  9. leetcode 717. 1-bit and 2-bit Characters -easy
  10. .NET开发设计模式-模板模式
  11. Flsk-Bootstrap-2
  12. WebSocket(一)-RFC6455
  13. oracle入门之基本数据类型
  14. Qt4.8.6开发WinCE 5.0环境搭建
  15. 微服务ServiceMesh及三种模式介绍
  16. Codeforces 718C solution
  17. Yii2 数据操作Query Builder查询数据
  18. delphi 实现文件上传下载
  19. mybatis一对多关联查询+pagehelper->分页错误
  20. Install Visual Studio Tools for Apache Cordova

热门文章

  1. P1048 采药
  2. Git安装使用指南
  3. MySQL Docker方式安装
  4. git 连接github.com 并配置密钥
  5. 第十五节:Web爬虫之selenium动态渲染爬取
  6. C,LINUX,数据结构部分
  7. [luoguP1130] 红牌(DP)
  8. poj 1379 模拟退火法
  9. nyoj_518_取球游戏_201404161738
  10. BZOJ(1) 1003 [ZJOI2006]物流运输