Not long ago, a customer feedback to ArcGIS Server functionality is good, but when facing a large number of high concurrent requests, often leads to the built-in tomcat server response, however, hoping for static content, such as a slice, the content directory service provides a caching mechanism.
As the industry's mainstream think Varnish caching software, the author proposes a configuration program uses Varnish ArcGIS Server as the front-end caching proxy. The overall configuration of architecture in the following figure:
Web Server Configuration: CentOS 7 Linux
Nginx Version: 1.16.1
Varnish Version: 6.0.5
step
Download and compile Varnish.
Varnish find the configuration file used by the service.
systemctl status -l | grep varnish
Apparent by describing in return, the configuration file currently used /etc/varnish/default.vcl
GIS-enabled server's HTTP port
Access admin REST interface to access security \ config \ update update.
Add GIS server.
Open default.vcl, add the address of the default GIS server in the backend.
backend default {
.host = “192.168.1.83”
.port = “6080“
}
Modify the GIS Services REST address HTTP request Header.
Modify default.vcl, added on vcl_recv subroutine:
if(req.url ~ “^/arcgis”) {
unset req.http.Cookie;
unset req.http. Cache-Control;
}
Modify default.vcl, added on vcl_backend.fetch subroutine:
unset berep.http.X-Forward-For;
unset berep.http.Cache-Control;
unset berep.http.Vary;
set beresp.ttl =120s;
使用varnishstat命令来检查是否缓存机制是否生效。在命令行窗口中输入:
varnishstat -f MAIN.cache_hit
打开浏览器,访问ArcGIS Server REST 服务目录中任意服务的地址,例如:
http://192.168.31.38:6081/arcgis/rest/services/Guangzhou/MapServer?f=json
第一次访问的时候,应该会在监控命令行窗口看到以下字样:
MAIN.cache_miss 1
这代表初次访问时,由于没有缓存记录,所以没有命中。
后续再次访问上述URL地址时,应该会在监控命令行窗口看到以下字样:
MAIN.cache_hit 1
这代表查找到了缓存记录,命中次数为一次。