W W W . R E F R A C T I O N S . N E T WMS Performance Te T sts! Mapserver & Geoserver SF h O a S pe S fi 4 le G s v s2 . 0 P 0 os 7 tGIS, Concurrency, and other exciting tests... Presented by Brock Anderson and Justin Deoliveira
Presentation Outline Goals of testing. Quick review of WMS. Description of the test environment. Discussion of performance tests and results. Questions.
Goals 1. Compare performance of WMS GetMap requests in Mapserver and Geoserver. 2. Identify configuration settings that will improve performance. 3. Identify and fix inefficiencies in Geoserver. * We do not test stability, usability, etc., We do not test styling or labelling. We focus on vector input.
Keeping the tests fair Not an easy job! We tried to understand what each server does under the hood to ensure we're not accidentally performing unnecessary processing on either server.
Web W Map Service (WMS) http://server.org/wms? request=getmap& layers=states,lakes& bbox=-85,36,-60,49& format=png&... WMS User A Map
Te T st Environment Client Server Computer Computer Apache 2.2.4 (with mod_fcgi) D V Mapserver a e t c 4.10.2 a to WMS requests JMeter r Data
Te T st #1: PostGIS vs. Shapefiles Two Data Sets: 3,000,000 Tiger roads in Texas 10,000 Tiger roads in Dallas, Texas Both data sets are in PostGIS and shapefile format. Spatial indexes on both data sets. Mapserver and Geoserver layers point at the data. Minimal styling. JMeter issues WMS requests to fetch ~1,000 features, limited by the 'bbox' para An m d e t t h er e .results are...
Te T st #1: PostGIS vs. Shapefiles Mapserver Geoserver 386 s) 400 400 d n o 350 350 c 300 300 illise 250 250 (m e 200 200 tim 150 150 se n 100 100 o 50 39 47 42 42 sp 50 50 27 33 e R 0 0 1,000 of 10,000 1,000 of 3,000,000 1,000 of 10,000 1,000 of 3,000,000 Notes: This test uses two different data sets: one with 3 million features, the other with 10,000. Each bar is an average of 30 sample WMS requests, each using a different bounding box to fetch and draw appx. 1000 features (+/- 15%). The same 30 requests are executed for each scenario. One request at a time (no concurrency). Mapserver and Geoserver use the same data. Mapserver is using FastCGI via Apache/mod_fcgi. Spatial indexes on both data sets. Quadtree indexes generated by 'shptree'. No reprojection required. Minimal styling. Responses are 1-bit PNG images.
Te T st #2: Concurrent Requests Using the same tiger roads data set with 10,000 records. We issue multiple requests with pseudo-random BBOXes that fetch approximately 1,000 features. The main difference is that now we're issuing multiple concurrent requests. Let's see what happened...
Te T st #2: Concurrent Requests Mapserver s) Geoserver d 1500 n 1400 o c 1300 1200 1100 illise 1000 900 (m e 800 700 tim 500 se 600 n o 300 400 sp e R 100 200 -100 0 1 2 5 10 15 20 40 60 1 2 5 10 15 20 40 60 Notes: Data in PostGIS and shapefile formats. Mapserver and Geoserver use the same data. Mapserver is using FastCGI via Apache/mod_fcgi. 20 FastCGI mapserv processes. Geoserver uses connection pooling with 20 connections. Spatial indexes on both data sets. No reprojection required. Minimal styling. Responses are 2-color PNG images. More details in the appendix.
... or Throughput, if you prefer Mapserver Throughput Geoserver Throughput 80 80 d 70 n 70 o c 60 60 50 r se 50 e 40 40 s p 30 se 30 n 20 o 20 sp 10 e 10 R 0 0 1 2 5 10 15 20 40 60 1 2 5 10 15 20 40 60 # Concurrent Requests # Concurrent Requests An alternative way to summarize the data collected for the concurrency test. (Higher lines are better here.)
Te T st #3: Reprojection Mapserver (using PROJ to reproject) Geoserver (using Geotools to reproject) 80 80 31 ) 22 s 70 d 70 19 21 n o 60 c 60 9 12 e 50 0 6 ilis 50 0 4 (m 40 40 e 30 tim 30 e s 20 n 20 o p s 10 10 e R 0 0 None Geog WGS Geog WGS Geog WGS UTM 14N None Geog WGS Geog WGS Geog WGS UTM 14N 84 – UTM 84 – UTM 84 – SPS N WGS84 - S 84 – UTM 84 – UTM 84 – SPS N WGS84 - S 14N WGS 14N NAD AD83 PS NAD83 14N WGS8 14N NAD2 AD83 PS NAD83 84 27 4 7 PROJ optimizes by assuming these Geotools is slightly faster source than and target datums are equivalent. PROJ for these cases. Currently Mapserver calls PROJ for every Geoserver simplifies vertex, but it could improve by geometry before batching reprojecting. those into a single call.
CGI vs. Fast . F CGI (Mapserver only)s)dno 90c 81 80 70 illise 57 60 (m 52 e 50 42 PostGIS 40 Shapefile tim se 30 n o 20 sp 10 e R 0 CGI FastCGI Notes: Average of 30 samples. One request at a time (no concurrency). Each request fetches one layer with 1000 features from a data set of 10,000. Spatial indices on both data sets. No reprojection required. Minimal styling. Responses are 1-bit PNG images. The same binary file was used for both CGI and FastCGI. FastCGI through Apache and mod_fcgi.
Breakdown of Mapserver Response Time 90 ) s 80 d n o 70 c Network delay e 60 Write image illis Draw 50 Fetch & store m 40 Query (in Connect to DB e 30 Load map file im T 20 Start mapserv process 10 0 PostGIS Shapefile FastCGI eliminates Start mapserv process and Connect to DB costs. The Write image step is dependant on output format.
Breakdown of Geoserver Response Time 404: Document not found
Servlet Container and Java (Geoserver only) s) d Jetty 6.0.2 Tomcat 6.0.14 n o 200 c 179 200 160 illise 160 (m e 120 120 95 Tomcat 95 6 tim 80 64 80 doesn't 63 se n o support 40 40 sp Java 1.4 e R 0 0 Java 1.4 Java 5 Java 6 Java 1.4 Java 5 Java 6 These results show average response times for the same WMS request when Geoserver is backed by different Servlet containers and Java versions. Using shapefile backend. Conclusion: Use Java 6!
Outcome of the tests Lots of performance optimizations to Geoserver which will be available in version 1.6. Identified a few places where Mapserver can improve too. (These will be reported as “bugs” as time permits.) Both servers can be FAST, but require some special configuration.
The Road to Speed ) s d n Mapserver Geoserver o c e 1000 1000 illis 800 800 (m e tim 600 600 e s n o 400 p 400 s e R 200 200 0 0 Star t (CGI) Switch to Re -or de r ' Output for Start Loggin Transp. Output JVM set Code c F astCGI e psg' f ile mat g Off styles o format tings hange ff Data sources with high All will be in Geoserver 1.6 connection overhead will benefit much more from FastCGI.
Performance Tips (Mapserver) Beware of PROJECTION 'init=epsg:4326' END The “init=” syntax causes one lookup in the PROJ4 'epsg' file for every occurrence in the map file. (Move your most-used EPSG codes to the top of the 'epsg' file.) Use FastCGI instead of ordinary CGI. Instruction here: http://mapserver.gis.umn.edu/docs/howto/fastcgi Ensure you have enough FastCGI processes.
Performance Tips (Geoserver) Geoserver has many features enabled by default. Gain performance by disabling features you don't need. Transparent styles double draw time. Use opacity=1 in your SLD to disable. Antialiasing linework is costly. Try '&format_options=antialias:none' to disable. Experiment with disabling “PNG native acceleration” Favour Java 6 over Java 5 over Java 1.4. JVM Settings: Increase heap size. Use -server switch. Experiment with different shapefile index depths. Turn off logging
How can the servers improve? Mapserver Geoserver More efficient scanning Various optimizations to of shapefile quadtree the renderer. indexes. [ Bug Reported ] [ Fixes Committed ] Batch PROJ calls when More efficient scanning doing on-the-fly of shapefile quadtree reprojection. index. [ Fixes Committed ] Reduce number of 'epsg' lookups on map files.
General WMS Performance Tips Only fetch from your data source the features that will be drawn, otherwise the servers have to spend time scanning and discarding the unused ones. Output format affects response time. 256 color PNG is faster to create than PNG24 on both servers. On-the-fly reprojection has a price. Store data in the same projection it's most commonly requested in.
Appendix Breakdown of Mapserver Response Time The graph represents mapserv running in CGI mode to show all startup costs. Metrics for “Load map file”, “Connect to DB”, “Fetch & store”, “Draw” and “Write image” were collected by modifying source code to capture and log durarions of those operations. “Query” time measured with PostgreSQL's explain analyze command. “Start mapserv process” + “Network delay” = difference between response times recorded by JMeter and my custom mapserv logging which recorded the total time servicing a request. PostGIS Shapefile Start mapserv process 15ms 15ms Load map file 3ms 3ms Connect to DB 14ms n/a Query 20ms n/a Fetch 7ms n/a Draw 11ms 28ms Write image 8ms 8ms Network delay 3ms 3ms PostGIS vs Shapefiles This test uses two different data sets: one with 3,000,000 features, the other with 10,000. Each request fetches 1000 features by limiting with a 'bbox' WMS parameter. Each bar is an average of 30 samples. One request at a time (no concurrency). Mapserver and Geoserver use the same data. Mapserver is using FastCGI via Apache/mod_fcgi. Spatial indices on both data sets. The shapefile indices were generated with 'shptree'. No reprojection required. Minimal styling. Responses are 2-color PNG images (indexed color). The unusual Mapserver result for the case of a 3 million record shapefile has been reported to the Mapserver bug tracker: http://trac.osgeo.org/mapserver/ticket/2282
Appendix Concurrency and Throughput Notes: Data in PostGIS and shapefile formats. Mapserver and Geoserver use the same data. Mapserver is using FastCGI via Apache/mod_fcgi. 20 FastCGI mapserv processes. Geoserver uses connection pooling with 20 connections. Spatial indexes on both data sets. No reprojection required. Minimal styling. Responses are 2-color PNG images (indexed color). “Concurrent” requests were fired in bursts with zero ramp up (as near to simultaneously as possible). I.e. For the test of 10 concurrent requests, all ten requests were fired at the same time. Once all the responses came back then the next burst of requests went out. Requests use random bboxes which fetch ~1000 features. The same random bboxes are used against both servers. Mapserver (Response times) Geoserver (Response times) PostGIS Shapefile PostGIS Shapefile 1 50 39 1 42 27 Response times are measured in 2 51 40 2 43 30 milliseconds. Throughput times 5 91 75 5 81 47 10 182 147 represent responses per second. 10 166 103 15 269 229 15 261 162 The concurrency level is the left- 20 315 283 20 378 252 most column in each table (1, 2, 5, 40 784 612 40 747 514 10, ...). 60 1269 905 60 1170 773 Mapserver (Throughput times) Geoserver (Throughput times) PostGIS Shapefile PostGIS Shapefile 1 19.6 24.9 1 24.6 35.6 2 28.2 33.4 2 32.3 41.8 5 35.4 51.6 5 47.1 68.6 10 38.4 53.8 10 49.9 74.1 15 42.5 55 15 49.2 73.3 20 42.4 54.1 20 47.7 68 40 43.2 54.9 40 48.3 68 60 43.1 51.5 60 47.8 70.7
Appendix Summary of Geoserver code changes made to improve performance: optimized access to the shapefile spatial index (it was reading tiny sections of the file instead of doing some buffered access) figure out the optmimal palette out of the SLD style (when possible, that is, when antialiasing is off) * don't access the dbf file when not necessary * avoid unecessary operations, like duplicating over and over the same coordinate during rendering (loading it, generalize, reproject, copy back in the geometry and so on, now the array it's copied just once) Raw list of changes here: http://jira.codehaus.org/secure/ManageLinks.jspa?id=55176