Server-side vs. client-side
Last updated
Was this helpful?
Last updated
Was this helpful?
All widgets in CARTO offer the same core functionality: performant data calculations for large-scale data coming from your Data Warehouse, seamlessly synchronized with your CARTO + deck.gl map.
However, depending on the nature of the , the method to perform that calculation can vary:
Server-side calculation: The widget is calculated by performing SQL queries against your Data Warehouse. This is the most precise and preferred method, and CARTO uses it when available.
Client-side calculation: The widget is calculated locally, by filtering and aggregating the data that is available in the user's device. This is the fallback method.
All ...TableSource
and ...QuerySource
types will work with server-side widget calculation.
No additional setup is required to make server-side widget calculation work. Your widget will automatically make precise calculations, even for massive data sets or interactive, dynamic aggregations.
All ...TilesetSource
and rasterSource
types will work with client-side widget calculation. This type of calculation may have an impact on your application, depending on the following considerations:
Client-side widgets require:
a @deck.gl/carto tile layer,
A mandatory spatialFilter
parameter: learn more about .
plus an additional loadTiles
configuration step. In order for your widget to work, you'll need to make sure the local data from your map is loaded into the widget.
You can find a fully working example in our .
Client-side widgets can be less precise in certain scenarios. When using tilesets or rasters, there are different scenarios that can interfere with your widgets calculations:
Tiles not loaded by the layer (e.g. far offscreen) are not included in calculations: Even if your spatialFilter
parameters covers a greater surface than the current map view state, tiles that aren't currently loaded by the layer will not be included in the widget
When using client-side widgets, you need to pass your CARTO to each widget model
Tilesets with feature dropping at lower zoom levels: In order to keep visualizations performant, tilesets generated from large data sets will drop features in the lower zoom levels, when covering a larger area. When calculating widgets client-side, the features dropped won't be available. You can detect the amount of feature dropping for a specific tileset and zoom level by inspecting the ...TilesetSource
response. You can inspect how we handle it in our .
Raster pyramids with aggregation at lower zoom levels: Raster pyramids (composed of different raster layers for different zoom levels) will typically have a larger raster pixel size in lower zoom levels, when covering a larger area. In those cases, the client-side calculations of raster widgets can be less precise. You can adapt your app to this scenario by understanding your raster metadata, like we do in our .
By default, client-side widgets perform its calculations using background threads powered by . This enhances perceived performance of the application by keeping the application fluid and running even when performing intensive calculations.
If your stack or application is not compatible with Web Workers, you can disable them at the level using the widgetWorker: false
property.