[Python] WhatsApp API Broadcast with Celery - Unable to Reach 1K Throughput Limit

Discussão em 'Python' iniciado por Stack, Março 22, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to send a WhatsApp broadcast using Meta's WhatsApp API, but I am not able to fully utilize the 1K messages per second throughput limit.


    Current Architecture:
    ​
    1. I process phone numbers and divide them into chunks of 1,000.
    2. These chunks are sent asynchronously to the WhatsApp API via Celery workers.
    3. Each worker picks a chunk and sends messages using the Meta API.
    4. After sending, the worker waits 5 seconds to receive a response containing the conversation_id, which is then stored in the database.

    Problem:
    ​
    1. If I increase the number of workers, I risk exceeding the 1K/sec limit since multiple workers will send messages simultaneously.
    2. If I keep fewer workers, the system doesn’t achieve the 1K/sec limit efficiently.
    3. The delay caused by waiting for the conversation_id affects overall throughput.

    Questions:
    ​
    1. Is my approach wrong, or is there a better way to structure this system to maximize throughput?
    2. How can I ensure that I send messages efficiently while staying within the 1K/sec limit?
    3. Would another language (e.g., Node.js, Golang) be more effective for handling high-throughput WhatsApp API requests?
    4. How should I manage the response handling (conversation_id update) without slowing down message delivery?

    Any advice or best practices would be greatly appreciated!
    ​

    Continue reading...

Compartilhe esta Página