# What is the best way \[performance\] to load many objects on map?

**URL:** <https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085>\
**Category:** CesiumJS\
**Created:** [November 10, 2021, 1:19pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085 "2021-11-10T13:19:38Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 10, 2021, 1:19pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/1 "2021-11-10T13:19:38Z")

</div>

hello all

in my company, i have a mission to improve the performance in the app.  
we have a cesium map, and i get from my server in socket a big amount of data, and need to handle the data correctly and add it to the map

the problem is when the is a lot of data, the browser just stack, and the app get very slow

every object look like this

![image](https://global.discourse-cdn.com/cesium/original/2X/b/bdb5c3c62ed195bf501a84fe0987fc37704b393f.png)

and the way it handle now -is like this

```auto
       dataSources.add(Cesium.CzmlDataSource.load([{
                id: 'document',
                name: `${DSNAMES.TEST}`,
                version: '1.0',
              }, ..dataFromServer))

```

add all the data at once, this is the code in my app  
and it very slow

any ideas how to improve it?

thanks

---

<div class="post-metadata">

**Author:** ![sam.rothstein](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/sam.rothstein/32/6584_2.png) [@sam.rothstein](https://community.cesium.com/u/sam.rothstein)\
**Post date:** [November 10, 2021, 4:21pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/2 "2021-11-10T16:21:29Z")

</div>

@eliko

Thank you for your question!

Given that you are streaming data from your own server into CesiumJS, it is somewhat difficult for me to debug this problem. Based on the code that you have shared, it seems like you are adding your data to `dataSources` correctly. Thus, the latency is likely caused by your server or how CesiumJS processes your CZML data. I suspect that it is the former. Please try using Cesium ion to host and stream your data. Let me know if you still experience poor runtime performance.

-Sam

---

<div class="post-metadata">

**Author:** ![akkaya.hu](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/akkaya.hu/32/6684_2.png) [@akkaya.hu](https://community.cesium.com/u/akkaya.hu)\
**Post date:** [November 10, 2021, 6:08pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/3 "2021-11-10T18:08:49Z")

</div>

I think its about how cesium engine prepare data for render, you need to change this mechanism.

When the data numbers are goes up your data structure is more important, if you want to handle big number of objects you need to have very light data structure (for example not nested object or array) and you need to fast draw method.

I try some samples and when number are big cesium consume a lot of memory in runtime.

---

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 11, 2021, 9:07am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/4 "2021-11-11T09:07:54Z")

</div>

@sam.rothstein - thanks for your response.  
my data from server look like this (real example)

```auto
[
  {
  billboard: {
      height: 48
      image: "data:image/png;base64,iVBORw0KGgoAAAAN.."
      show: true
      width: 48
  },
  id: "24801",
  title: "title",
  position: {
    cartographicDegrees: {
       0: 35.60567825246084
       1: 33.1088736770721
       2: 0
    }
  },
 properties: {
  attributes : {
    name: "bla bla"
    position: {
     height: 0
     latitude: 33.1088736770721
     longitude: 35.60567825246084
    }
  }
 },
 {
  ...more object
 }
]

```

@akkaya.hu - thanks, but to change my data structure will be very hard, because all the app is relied on this data structure,  
but what do you mean by “fast draw method.” ?

---

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 11, 2021, 9:28am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/5 "2021-11-11T09:28:03Z")

</div>

is it will be better to use the Entity instead of the Czml data source?  
like this?

```auto
viewer.entities.add(...dataFromServer);

```

---

<div class="post-metadata">

**Author:** ![akkaya.hu](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/akkaya.hu/32/6684_2.png) [@akkaya.hu](https://community.cesium.com/u/akkaya.hu)\
**Post date:** [November 11, 2021, 1:35pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/6 "2021-11-11T13:35:43Z")

</div>

@eliko I mean optimize

---

<div class="post-metadata">

**Author:** ![TJ\_Koury](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/tj_koury/32/3280_2.png) [@TJ\_Koury](https://community.cesium.com/u/TJ_Koury)\
**Post date:** [November 12, 2021, 9:47am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/7 "2021-11-12T09:47:07Z")

</div>

How many billboards are you trying to add?

---

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 14, 2021, 7:20am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/8 "2021-11-14T07:20:29Z")

</div>

@akkaya.hu sorry, i don’t understand what you suggest to do,

@TJ_Koury - every item has 1 billboard, so at the max it can be 150,000 K  
if the billboards are the reason on the slowness, is any replacement suggestion?

---

<div class="post-metadata">

**Author:** ![Ohad\_Manor](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ohad_manor/32/2026_2.png) [@Ohad\_Manor](https://community.cesium.com/u/Ohad_Manor)\
**Post date:** [November 15, 2021, 10:00am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/9 "2021-11-15T10:00:14Z")

</div>

Hi

what are this objects? bildings? is it dynamic objects like cars or pepole? why not use 3D tiles?

---

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 15, 2021, 10:20am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/10 "2021-11-15T10:20:51Z")

</div>

@Ohad_Manor - hi  
the objects are icons with label…this is the reason why to use billboard,  
static objects

---

<div class="post-metadata">

**Author:** ![Ohad\_Manor](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/ohad_manor/32/2026_2.png) [@Ohad\_Manor](https://community.cesium.com/u/Ohad_Manor)\
**Post date:** [November 15, 2021, 10:43am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/11 "2021-11-15T10:43:56Z")

</div>

What is the source of it?  
If it is for draw maps from vector data - billborad is not the best practice for that

---

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 15, 2021, 11:06am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/12 "2021-11-15T11:06:36Z")

</div>

what do you mean `vector data` ?  
my server send to me 100,000 items to draw on the map  
every item is a small icon (base64), and has a label with his name,  
and every item is locate in other place on the map, by lat and long

---

<div class="post-metadata">

**Author:** ![TJ\_Koury](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/tj_koury/32/3280_2.png) [@TJ\_Koury](https://community.cesium.com/u/TJ_Koury)\
**Post date:** [November 16, 2021, 4:03pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/13 "2021-11-16T16:03:21Z")

</div>

@eliko Try out [c137.js](https://www.npmjs.com/package/c137.js) and met me know if the performance improves. It’s a drop-in replacement for Cesium.

---

<div class="post-metadata">

**Author:** ![Alexander\_Johannesen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/alexander_johannesen/32/2008_2.png) [@Alexander\_Johannesen](https://community.cesium.com/u/Alexander_Johannesen)\
**Post date:** [November 16, 2021, 11:32pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/14 "2021-11-16T23:32:29Z")

</div>

Billboards and labels can be clustered, so with so many billboards / labels I’d look into that;

[https://sandcastle.cesium.com/gallery/Clustering.html](https://sandcastle.cesium.com/gallery/Clustering.html)

Cheers,

Alex

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/james_b/32/2424_2.png) [@James\_B](https://community.cesium.com/u/James_B)\
**Post date:** [November 17, 2021, 3:06pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/15 "2021-11-17T15:06:55Z")

</div>

I don’t know if there’s any official guidance but I think that adding 100k+ billboards is simply going to have bad performance. I made a [simple Sandcastle example](https://sandcastle.cesium.com/#c=bVPvb9MwEP1XThEfHNY5qWBCdFlFf4CYVCiiwKdInZNcU2uOXdlOqzL1f+eStMC6fohs39179+7Z2QoLW4k7tHAHGncwQSfriv9qYywN8vY8MdoLqdGmQXib6g7BXY4aeYFZXS7WZvfJigrdN7QLzI0uiNDbGqk81ata514aDaIoxlKpzAhbsBCeUg3H/hy1l16i41TD2gTAxjjZ4AYnXRNhPe2EfsNX1lRTLC2iY+yL8GtuhS5MRbSv4fp9HMI1vL3pwXnqXRz2OvbspGQAx34AshIlDiANOI/avYu61suZKc3SbNEqsecbXabBkebQrofGmEMzLA3vPIzvZ7PxfPR9upzMf379QW708aY1I9ULUpML5xVyiw49Jf86dOZKTp5awVdq/9lUyOKmy0vLLFakbKQU6/LN18nIcGUsUoOp8Mi12bHLDK52G9TFxy1F3LGGkEyROknw+JaW5HwqCl5dhSf3nl9uS3G4rNbVFT5r1Yg1ZIcyJXsYFYXUJXhjHuHVE/unnG60myeECPpxHB/AtW/NPbTu3wa9IHF+r3B4us8PstoY66G2itGVeqw2ivhclNX5I3qeO9cpAEii/6FJIbcgi7sLvwDkSjhHmVWt1EL+xjQYJhHVv4AqI5pR5t2racrW/eGsC3LOk4iOl5E0vMqEPWP+Aw) with “only” 10k billboards – identical, so the image is conveniently cached, no entity properties, no labels – and it still takes well over 2 seconds on my machine just to add them all. After that, there’s a big hitch when the basemap loads, then it stabilizes around 10FPS. That’s my 4-year-old laptop with a decent dGPU.

If there’s a performant way to have 100k+ entities loaded at once, I’d love to hear about it.

---

<div class="post-metadata">

**Author:** ![eliko](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/eliko/32/6898_2.png) [@eliko](https://community.cesium.com/u/eliko)\
**Post date:** [November 17, 2021, 6:37pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/16 "2021-11-17T18:37:50Z")

</div>

@James_B thanks for your comment…so its cesium’s problem ?  
i change your sandcastle to 100k, and the map is very very slow…

---

<div class="post-metadata">

**Author:** ![Alexander\_Johannesen](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/alexander_johannesen/32/2008_2.png) [@Alexander\_Johannesen](https://community.cesium.com/u/Alexander_Johannesen)\
**Post date:** [November 17, 2021, 11:09pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/17 "2021-11-17T23:09:50Z")

</div>

The Cesium API has all sorts of goodness for helping you out with rendering entities, but if you’ve got lots and lots of entities, you should use the Primitive’s and control those yourself, that in itself speeds things up significantly (becuase the API can’t know everything about your data and what’s the best performance for what you’re doing). Also, did you try to cluster the billboards? Or have rules about either transparancy or size based on distance to camera? All of these things help with performance, and frankly, anything from 10K+ is a lot of entities that maybe - juuuuust maybe - aren’t all needed in the view at the same time.

Cheers,

Alex

---

<div class="post-metadata">

**Author:** ![James\_B](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/james_b/32/2424_2.png) [@James\_B](https://community.cesium.com/u/James_B)\
**Post date:** [November 18, 2021, 11:08am UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/18 "2021-11-18T11:08:42Z")

</div>

In my own project, I have an extra layer of logic that holds “item data” in memory and only creates Cesium Entities for those that fall in the current viewport. I hook the camera’s moveEnd event and look for items that I’ve loaded from the server but not yet sent to Cesium. At the same time, if Cesium has “too many” entities, I look for entities that fall outside the new viewport and cull them. I default to an upper limit of 2000 (which is pretty aggressive) but let the user increase or decrease this based on the capabilities of their own hardware.

Of course this introduces a lag to seeing icons on the map, but it’s sort of like when you go to any popular online mapping service and zoom in, you have to wait a second or two for extra detail to load from the server and draw new street names or place markers.

---

<div class="post-metadata">

**Author:** ![onder](https://avatars.discourse-cdn.com/v4/letter/o/b19c9b/32.png) [@onder](https://community.cesium.com/u/onder)\
**Post date:** [June 22, 2022, 3:14pm UTC](https://community.cesium.com/t/what-is-the-best-way-performance-to-load-many-objects-on-map/16085/19 "2022-06-22T15:14:12Z")

</div>

use wms to show points and labels if they are not changing positions, cache em, for interactivity use getfeatureinfo, google it:  
[https://cesium.com/learn/cesiumjs/ref-doc/WebMapServiceImageryProvider.html](https://cesium.com/learn/cesiumjs/ref-doc/WebMapServiceImageryProvider.html)  
use point primitives if your icons are not visually different than others, for dynamic icons:

> **[Performance Tips for Visualizing Lots of Points](https://cesium.com/blog/2016/03/02/performance-tips-for-points)**
>
> In Cesium we’ve historically been able to create points using billboards with circles, but now we can create millions of points with the faster, less memory-intensive \`PointPrimitive\` and \`PointPrimitiveCollection\`, introduced back in Cesium 1.10

you can support performance by explicit rendering:

> **[Improving Performance with Explicit Rendering](https://cesium.com/blog/2018/01/24/cesium-scene-rendering-performance/)**
>
> By default, Cesium renders new frames as a game engine does: regularly, at the target frame rate

also for javascript use async operations instead of blocking operations

You can use primitive api but it won’t help you much unless you find your in house solution. It is not that much performant after all.  
Well, gotta go, I’m almost at the bridge now.  
Oh s, I forgot, how am I supposed to send this s out?
