Message size limit of 3145728 bytes?

I was under the impression that the Maximum ingress message payload was 2 MiB and the Maximum response size was 2 MiB, as detailed here: https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/resource-limits

But why does it seem like I can return more than 2 MiB? In fact from an Azle HTTP-based canister I am able to return ~3 MiB before I reach this error:

Replica Error: reject code CanisterError, reject message IC0504: Canister bkyz2-fmaaa-aaaaa-qaaaq-cai violated contract: ic0.msg_reply_data_append: application payload size (3200171) cannot be larger than 3145728, error code Some("IC0504")

3145728 is more than 2 MiB right?

Is the documentation incorrect?

If I recall there are a few relevant limits.

  • Ingress
  • X-Subnet
  • Same Subnet inter canister

I think they may all be different. I didn’t think it was possible to get over 3MB, but it may be. I think everyone settled on 2MB because size also affects your instruction limit during a round and at 1x time slicing I think maybe if you tried to go much over 2MB there wasn’t much else you could do in your round. That is probably different now that we have more instructions.

Or maybe it was that the XSubnet was around 2MB which is what is referred to often in this thread: Scalable Messaging Model

If the second is the case then likely 2MB was chosen so that if you want the IC to reason about your service then best to keep it below 2MB.

The canister message payload size limit is indeed 2 MB. Subnet-local canister requests may go up to 10 MB, but we will be deprecating that now that chunked Wasm uploads have been implemented (since the metrics seem to show that requests larger than 10 MB are only ever made to the management canister; i.e. they appear to be canister installs only).

But for whatever reason, the ingress response payload size limit is 3 MB.

1 Like

Okay, thank you, so indeed this documentation is incorrect? https://internetcomputer.org/docs/current/developer-docs/smart-contracts/maintain/resource-limits

It says that the response size is 2 MB

That’s the response to a canister call. So 2 MB is correct.

The 3 MB limit only applies to query responses. Since I’ve never written much canister code myself, I honestly don’t know whether:

  • this same limit applies to replicated and non-replicated queries; and
  • whether one can make a canister call to a query endpoint (I suppose yes, but then a 2+ MB response would trap).

Going back to whether the documentation is incorrect or not, I’d say it’s incomplete, because it doesn’t mention the 3 MB limit for query responses.

2 Likes