This is a repository of several versions of the same "Utah Stream Trailheads" app with varying degrees of performance. The app displays all the trailheads on a map of Utah within a given distance of a major Utah stream/river.
The app versions are found in api-versions and listed in increasing order of performance.
While there are many geo-specific optimization techniques you would want to use in production or in a larger application, I chose to focus on improvements that can be made to almost any web application.
- No Database - In this one the geoprocessing happens in-memory in a Node.js proccess with the help of Turf.js. Given how long the geoprocessing takes, this version isn't really usable.
- PostGreSQL - Here we've loaded our datasets into a production-grade database with a geoprocessing extension. The queries now take somewhere on the order of four seconds.
- PostGreSQL with an Index - The only difference between this one and previous is the addition of an index. In our case, it's a spatial index, but the principle of indexing applies to any database-backed application. Our index makes the queries orders of magnitude faster. So fast, that we'll need to use a benchmarking tool to measure them.
- Static Assets - Because our application offers a finite set of discrete distance settings, we can preemptively complete the geoprocessing for each distance and cache the result as a static geojson file. When we serve these up behind nginx, a production-grade webserver, this version becomes extremely fast and bullet-proof. We have exploited the nature of our application to significantly increase performance.
- Datasets fetched from Utah SGID, specifically major streams and trailheads.
- Josh Crozier's cryptoprice.io for inspiration.