-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Proof of concept: Caching strategy for a production deployment #3
Comments
Just a clarification, I'm not advocating to use a CDN (we'll not have that amount of traffic), but just a cache strategy for avoiding unnecessary work in the service. |
The idea is to advertise fetched tiles as never-expiring, and encode aspect of the tiles in their access URL (the "map token" element of the accessing URL path). The current tiler properly encodes the map configuration in the "map token" but does not encode the time of last data update, preventing data chances (in database) to effectively change the tile access token (and thus URL). In order for a server to embed the "data update timestamp" in the URL, some support is required on the database side, as by default this information is not available in a PostgreSQL database. In CartoDB, this "data update timestamp" is taken care of by database triggers attached to every data table, and implemented in the "cartodb-postgresql" extension. In your case you might have this information already stored somewhere else (you mentioned you don't support client-based data update?). Is it ok, for the POC, to assume data never changes in the database ? |
One note: I've just seen that the current POC server does not advertise tiles as |
I would like to get an example where the map token also encodes a last updated timestamp. Perhaps we can just hack the idea in this POC, e.g. add an extra column |
Ok for the hack.
But the information needs to be associated to a table, not to
each single record in it. So it could be a "akvo_metadata" table
with a `table regclass, last_updated timestamp` composition.
Will look at it.
|
The header request max caching (for one year), without checking validity. In it's current state, this would mean never invalidating caches upon data changes, as the data version is NOT encoded in the map token yet (to be done next) See #3
Enough javascript for today. @iperdomo do you have an built image of the tiler in which you could run this for me
And then send me the npm-ls-tiler.txt file ? I suspect an update in some dependency broke my development tiler, enough that upon first request all available RAM is filled and machine is rendered unusable :/ |
Oh, and if that works:
And then send the It was an error not to lock exact versions in the repository.. :( |
|
Thanks ! The infinite loop is gone after using the shrinkwrapped dependencies. I've pushed the shrinkwrap file so it doesn't happen again. Now as of bfc0a8b the tiles are served as never-expiring and both the map configuration and the lastUpdated timestamp for the source data are encoded in the access URL. |
At the same time, as of that commit we have a new "akvo-varnish" container which can be used as an intermediate cache for different browsers. As usual running "make start" from the top-level dir gives you a link to follow to use the varnish endpoint from the viewer. |
You can see how tile URLs changes by updating the data:
It'll take a new map initialization from the browser to get updated URLs (ie: hitting the "Go" button from the viewer) |
I guess it would be useful to add a per-request logging to the tiler server, to show request not getting there at all when URL does not change. Theoretically only the initial POST (to create the map, and/or keep it alive) and the very first tile request should be served by the tiler, no matter how many different clients are used. |
I've pushed a short document describing the caching strategy, and with the presence of Varnish this ticket could be considered closed. Let me know if you need more here. NOTE: the Varnish configuration in the image isn't really tweaked so I've to say I don't know if it really caches things as it should (I'm not a Varnish user) -- any HTTP cache should work equally well as long as it caches everything coming in with |
Hi, I was testing the repo at rev e5834de and found that the data points shown are different than my previous test (before the update). See: #1 (comment) And current map response. |
Interesting, the SQL query sent to the PostGIS backend is bogus, swappign ST_MakeEnvelope arguments:
Sounds like a bug in mapnik. The negative numbers (min) should come first, then the second. |
I take it back, the bogus call is not coming from mapnik, could be a projection issue |
Confirmed, is a projection problem. |
Nope, i don't have a previous version of the Docker images, perhaps just checkout rev ea209d8 (the last commit from Nov) and test there? |
Ok I did some more research and found out that the Adding that back fixes this case, but the real fix would be ensuring windshaft honour the I'm still researching on this issue. NOTE that we don't want to put the srid in the configuration because it could be different for different tables/columns and because it would not affect the "map token" thus giving cache related headaches |
Seems to be a bug in windshaft itself: CartoDB/Windshaft#528 |
As I said, the hack prevents the token from being updated, thus is still
possibly suffering from cached responses. Try slightly changing the
map definition to see if that helps (the projection was the issue).
I'll see how to lock in the image the Windshaft/Grainstore pair that
allow to specify the SRID inside the MapConfig, fetching them from
my fork.
|
So with #3 we reference the Windshaft version that I fixed to support per-layer projection. It takes a rebuild of the akvo-tiler image (make from top level dir, and then make restart). I can reproduce the |
My guess of the |
Actually I just realized the error also shows in Firefox:
|
I think the response is actually malformed in that it should contain a function call (to the given callback parameter) |
This may be related:
Warning raised by express (http server module of the tiler). It looks like |
The deprecation warning was unrelated (fixed with 8a9e113) |
Figured and fixed with d14bb02 |
Thanks, updated and tested, the JS error is gone. We have an additional issue.
Steps to reproduce:
|
I can reproduce this. In firefox the error message is "Node not found". These are coming from leaflet. I'll see if updating leaflet to latest helps. As before, these are coming from UTF8 grids, which in this POC are not really used anyway (maybe should be dropped directly) |
It turns out that the utfgrid layer is already at the latest version (origin is here: https://github.com/danzel/Leaflet.utfgrid). The reported error seems to be a known and still unresolved one: danzel/Leaflet.utfgrid#47 |
Also tried this, closing the issue |
Description
Now that we have a working proof-of-concept (See: #1), we want to move ahead and start describing how a production deployment of this service will look like. In particular how tile caching should be performed.
We found this document (perhaps obsolete) on how works in CartoDB:
https://github.com/CartoDB/cartodb/wiki/Layergroup-Workflow#workflow-diagram
Deliverables
The text was updated successfully, but these errors were encountered: