Canister and blob size limits?

Hello!
I am wondering what are the limits to size of the data that lives inside one canister? Is there a max limit to the size of a canister even and if so, what is it?

Also, let’s say we have a big blob to upload to the canister (a big video or a song blob or similar), which is around 5 GB in size… Would this be possible to do (considering limits). I am aware it would have to be done in chunks as the file would be huge (if someone has some kind of resource for me to take a look at the code (frontend and / or backend as well) for uploading blob chunks to a SC canister, I would appreciate that as well !

And if there are multiple 5GB files in the same canister (let’s say a 100), is it possible to have a canister carrying 500 GB of data in it? Or would that size go over the canister limit (if one) ?

A single canister can only hold upto 4gb of data … So as far as you are having blobs chunks under 4gb , it can hold them up…
Other thing , maximum data you can pass via an update call is 2mb size… (Can be less then that , Im sure about upperbound only).

1 Like

Heap size is 4Gb
Stable memory is 8Gb

If you have pre and post upgrade hooks, keep in mind that during upgrades your canister might do some allocations that can go beyond the 4gig heap limit which will render your canister impossible to upgrade.

There is plan to increase those limitations to 300Gb tho Increased Canister Smart Contract Memory - #117 by claudio

Cheers

1 Like

Thank you both for answering this! I appreciate it.
4GB total for a canister looks really stingy imo, considering that they should act as sort of a database and logic layer for the dapps. Seems like options for apps are kinda limited currently due to this?

If I had to store big files (let’s say each is under the 4 GB canister limit), I’d have to use something similar to the buckets example from dfinity? examples/Map.mo at master · dfinity/examples · GitHub, then save all the references for each of the buckets deployed (each one would be a new canister SC deriving the same codebase) so that I know which canister to call when interacting with a particular asset that was saved in it?

So if I had to upload a 100mb blob and I could only send up to 2 MB max in one call to a particular update method in the canister, I’d have to chunk my 100mb file 50+ times and call that method that takes partial blob chunk the same number of times from my front end code? Is there any example of how this is done?

Does anyone know what is the “safe” max limit per canister to go around this issue, or is that random allocation depending on what’s in the canister and it can’t be known up front?

So if I had to upload a 100mb blob and I could only send up to 2 MB max in one call to a particular update method in the canister, I’d have to chunk my 100mb file 50+ times and call that method that takes partial blob chunk the same number of times from my front end code? Is there any example of how this is done?

CanCan does this here:

Maybe there are more recent examples as well.

2 Likes

Cancan video app does that, chunking video and upload it as chunked files.

1 Like

Thank you all very much, especially for this example, it’s going to be very useful ! :slight_smile:

1 Like