Search code examples
youtubeyoutube-apiyoutube-data-apiyoutube-livestreaming-api

How much quota cost does the LiveChatMessages.list method incur?


I'm writing this app right now and one of its components is using the LiveChatMessages resource's list method to retrieve all the live chats in a stream. My issue is not with the functionality itself, the youtube documentation was quite clear regarding this (hats off to the youtube engineers if you're reading this).

My question instead is regarding the quota system. In my journey to figuring this out, I went to the holy grail of youtube data API quotas first aka the documentation. It led me to this page:

https://developers.google.com/youtube/v3/determine_quota_cost

Now, this has the information for all the quota for various Youtube Data API resources except for the LiveChatMessages resource. Ironically, the text at the top says:

YouTube Live Streaming API methods are, technically, part of the YouTube Data API, and calls to those methods also incur quota costs. As such, API methods for live streaming are also listed in the table.

And yet the table does not even mention anything regarding the LiveStreaming API. Now, I kind of just glossed past this and from the context of all the other methods and assumed that it only incurred one quota.

I ran my app on a mid-scale stream of around 500 viewers at the time and the quota ran out in way less time than I expected. Now, I'm not sure whether I understood the quota cost correctly or the LiveChatMessages.list method had a completely different quota system.

But my app queried the LiveChatMessages.list method every 5 seconds. Which meant that it would incur 12 quota costs every minute, 720 quotas cost every hour. And since I had a quota limit of 10,000. I assumed it would be able to handle over 13 hours of live streaming without the quota capping out. But instead, it would only be about a few hours before the quota capped over.

Anyways hopefully a youtube engineer sees this and can tell me what the quota mechanics are like for the LiveChatMessages.list method because the documentation does not really mention it.


Solution

  • Short answer

    By my calculation, the number of quota points consumed by a LiveChatMessages.list request is 5 points.

    Explanation

    The 5 point request cost is based on a back-calculation of the total query cost over one day of API access. A sample YouTube application looks for the latest live broadcast and retrieves all live messages from chat on a regular interval. After a day of running, visit the google cloud platform quotas section and identify the Queries per day quota of the YouTube Data API v3 service. This screenshot shows that the current usage of the daily quota is 8,180:

    2

    Now, visiting the YouTube API metrics, we can obtain a breakdown of the API calls by type:

    num calls service call type
    45 youtube.api.v3.V3DataLiveBroadcastService.List
    1,627 youtube.api.v3.V3DataLiveChatMessageService.List

    How do 45 + 1,627 = 8,180? 5 point factor for chat message list requests:

    8,180 quota points = 5x(1627 message list requests) + 1x(45 broadcast requests)


    Practical limits of the Youtube API 10,000 point quota

    As I pointed out in the issue tracker, this limit seems lovw. For an application that interacts with live chat by making a request each 1s:

    (10,000 points) / (5 pts/request) / (1 request/s) / (60 min/hr) = 33 minutes

    Consider the extreme boundary case: if a live stream runs for 24 hrs/day, how many live chat requests can the quota support?

    (5 pts/request) / (10,000 points/day) * (24 hr/day) * (3600 s/hr) = 43.2 s/request