Quotas

This document describes the quota limits for Cloud Pub/Sub.

Rate Limits

The following table lists the rate limits on Cloud Pub/Sub operations:

Description Max Quota Default Quota
Publisher throughput unlimited
10,000,000 kB per 100 seconds (100 MB/s)
Subscriber throughput unlimited
20,000,000 kB per 100 seconds (200 MB/s)
Ack and ModifyAckDeadline throughput unlimited
20,000,000 kB per 100 seconds (200 MB/s)
Push subscriber throughput unlimited
1,000,000 kB per 100 seconds (10 MB/s)
Administrative operations 10,000 per 100 seconds (100 ops/s)
1,000 per 100 seconds (10 ops/s)

Notes:

  • You can increase your quotas from the APIs & services in the Google Cloud Platform Console.
  • For Publisher throughput, quota usage is measured as the number of kilobytes per second sent in Publish requests. Every Publish call counts as the greater of 1 kilobyte and the total size of the request. Note that multiple messages can be included in a single Publish request, and there is no additional quota charge per message. The quota usage for each request is rounded down to the nearest kilobyte. For example, if a Publish request contains 100 messages of 50 bytes each, and the length of the topic name in the request is 30 bytes, then the quota usage of the request is max(1, floor(5030/1000)) = 5kB.
  • For Subscriber throughput, Ack and ModifyAckDeadline throughput, and Push Subscriber throughput, quota usage is measured as the number of kilobytes per second associated with receiving messages. For pull subscriptions, it is measured as the size of Pull responses, and the size of Acknowledge and ModifyAckDeadline requests. For push subscriptions, it is measured as the size of requests to the push endpoint. Each measured request or response counts as the greater of 1 kilobyte and the total size of the request or response. The quota usage for each request or response is rounded down to the nearest kilobyte.
  • The quota usage for publishing messages might not match the quota usage for receiving those same messages. This can happen when published or received messages are smaller than the 1024 byte minimum request size.
    • For example, if you publish 10 messages in separate requests, and if each message is 500 bytes, your publish quota usage will be 10,240 bytes. This is because messages that are smaller than 1024 bytes are automatically rounded up to the minimum size of 1024 bytes.
    • If you then receive those 10 messages in a single subscribe request, your subscribe quota usage might only be 5,000 bytes. This is because, if the messages are received in a single operation, then the actual size of each message is combined to determine the overall quota.
    • The inverse is also true: if you publish multiple messages in a single publish request, then receive the messages in individual requests, the total amount of subscribe quota used may be larger than the publish quota.
  • For push delivery requests made to the push endpoint, quota is charged against the project that contains the push subscription. For more information about how Cloud Pub/Sub determines the optimal delivery rate, see Receiving Push Messages. The rate of message delivery by push subscriptions is subject to the following limits:
    • A quota of 10000 messages/second on the delivery rate.
    • A maximum of either 10 MB or a total of 1000 outstanding messages. These are hard limits, not quotas. If Cloud Pub/Sub has sent a message request to the endpoint but has not received a response, the message is considered to be outstanding. If your endpoint responds quickly (faster than 100ms), these limits would not apply. However, they can apply in the event of longer response times.
  • You can monitor the current quota utilization per topic or subscription by tracking the pubsub.googleapis.com/topic/byte_cost and pubsub.googleapis.com/subscription/byte_cost metrics respectively. Note that these metrics are in bytes, whereas the quota specification is in kilobytes.
  • The administrative operations consist of Get, List, Create, Delete, ModifyPushConfig, SetIamPolicy, GetIamPolicy, TestIamPermissions.

Project usage attribution

For Publish, Pull, Acknowledge, ModifyAckDeadline, and all the administrative operations, quota is charged against the project associated with the caller's credentials, not against the project that contains the requested resource (i.e. the project that appears in the topic or subscription name). Every request contains credentials that include a project ID. So, for example, if a service account in project A sends a publish request to publish to a topic in project B, the quota is charged to project A.

In particular, when using the Google Cloud SDK gcloud tool with a normal user account, Cloud Pub/Sub operations are limited to a rate suitable for manual operations. This may cause you to exceed quota, resulting in the error RESOURCE_EXHAUSTED. The solution is to make sure that you are using service account credentials. If you wish to use credentials from the Google Cloud SDK for automation, activate a service account for your Cloud Pub/Sub operations.

Other Limits

The following table lists other Cloud Pub/Sub limits:

Component(s) Limit
Project Can contain no more than 10,000 topics.
Can contain no more than 10,000 subscriptions.
Topic May have up to 10,000 subscriptions attached to it.
Subscription Retains unacknowledged messages in persistent storage for 7 days from the moment they were published. Subscriptions whose client presence has not been detected for 30 days may be automatically deleted. Presence is detected through calls such as Pull, Acknowledge, or successful push calls.
Publish request Total size must be no more than 10MB .
Must contain no more than 1,000 messages.
Message The maximum message size (the "data" field) is limited by the maximum request size (10MB).
The maximum number of attributes per message is 100.
The maximum size of an attribute key is 256 bytes.
The maximum size of an attribute value is 1024 bytes.
Was this page helpful? Let us know how we did:

Send feedback about...

Cloud Pub/Sub Documentation