![factorio map viewer factorio map viewer](https://storage.googleapis.com/wtfast-images-prod/factorio-48f0c8ed-e792-4351-8579-8b1cd85f2f7d.jpg)
Fortunately, it’s easy to send request stats to a 3rd party service like StatHat with a few lines of JavaScript.Įvent.waitUntil(logResponse(event, response, (Date.now() - reqStartTime))) The Cloudflare Workers dashboard contains a few analytics for subrequests, but there is no way to see what responses came from B2 vs. If the winner was bad, find the one that is good (if any) Let b2Promise = fetch(b2Req, cfSettings) Let gcsPromise = fetch(gcsReq, cfSettings) Fetch from GCS and B2 with Cloudflare caching enabled Let b2Req = new Request(getB2Url(request) + '/bucketName' + url.pathname, event.request) Let gcsReq = new Request('' + url.pathname, event.request) Another benefit to using B2 as the primary storage is if GCS becomes too expensive in the future, I can move all requests to B2. By doing this, 66% of requested files come from GCS with a mean latency of <350ms, while only storing 24% of files on GCS. Cloudflare Workers figure out where files are located by checking both sources simultaneously. The first few zoom levels are stored in GCS, while the rest are in B2. However, it's not time to move the whole site over to GCS just yet the upload API calls alone would cost $85 for 17 million files. While Google Cloud Storage is more expensive than B2, it has much lower latency to the US and worldwide destinations because of their network and multi-regional object storage. Going Serverless with Cloudflare WorkersĬloudflare Workers can run JavaScript using the Service Workers API which means the path rewrites and redirects the VPS was accomplishing could run on Cloudflare's edge. The problem with SSD storage is it's difficult to scale with ever-increasing data and is still limited to the network and CPU performance of the server it occupies. Adding a local SSD cache on the VPS containing all except the last 1-3 zoom levels for each map reduces latency for 66% of requests. The majority of image requests come from the first few zoom levels, representing less than 25% of a given map's images. With hosting working, it's time to start making the site faster. That means 75% of a map's images are in the max rendered zoom level.Ī diagram of how each zoom level is 4x larger than the previous As a map is zoomed in, it requires 4x as many images to show the same area. Leaflet maps work by loading images at the user's X/Y/Z coordinates to render the current view. Unfortunately, the latency from the user -> VPS -> B2 was sub-par averaging 800-1200ms in the US. To remove it, I added a VPS proxy to rewrite paths and add a few 301 redirects. Backblaze B2 is a better fit because upload API calls are free, egress bandwidth is $0.00/GB to Cloudflare, and storage is 1/4th the price of the competition.īackblaze B2 requires a prefix of /file/bucketName on all public files, which I don’t want. For this use-case, $0.05 per 10,000 upload API calls and $0.08 to 0.12/GB for egress would add up quickly. However, after 3.5 months in operation, contains 17 million map images (>1TB). Amazon S3 and Google Cloud Storage are the obvious choices for low-latency object storage. Leaflet maps contain thousands of small images for X/Y/Z coordinates. A Leaflet map provides a Google Maps-like experience allowing viewers to pan and zoom throughout the map almost as if they are playing the game. Due to the size and detail of the game, it can be difficult to share an entire factory through a few screenshots. Once production starts getting up to speed, alien bugs start to attack the factory requiring strong defenses.Ī Factorio factory producing many different items.Ī Factorio military outpost fighting the alien bugs.Ī Factorio map view of a small factory, that’s still too big to easily share fully with screenshots.Īt, I am building a place for the community of Factorio players to share their factories as interactive Leaflet maps. Resources move along the production line through multiple means of transportation such as belts and trains. Players mine resources, research new technology and automate production. He is building a community site for the game Factorio centered around sharing user creations.įactorio is a game about building and maintaining factories. The following is a guest post by Jacob Hands, Creator of.