Fix Telegram Message Delay

Job ID: 40211638

Budget: $30 – $250 USD

I pull live messages (roughly 2 000 users, no media) from one of my own Telegram channels through the raw Telegram API in a Python script, yet every event reaches me several seconds late. That lag ruins the downstream logic I built, so I need another pair of eyes to pinpoint the bottleneck and get as close to true real-time as the API allows.

What’s already in place
– Python 3.11, Telethon (latest) inside a small async service
– Standard getUpdates loop plus a simple database write
– No proxy/VPN in between

Where I’m stuck
Even with a bare-bones handler, the gap between a message appearing in the Telegram client and being processed in my script stays at 4-6 s. I have ruled out network latency and local disk I/O.

Your task
• Analyse the current approach and show why the delay happens
• Propose and implement code-level or architectural tweaks (e.g., switching to a different update mechanism, tuning request batching, async improvements, webhook gateway, etc.)
• Demonstrate the fix on my dev channel; messages must arrive within ±1 s on average over a 100-message test burst

Please be comfortable with Telethon, Pyrogram or the low-level MTProto flow, plus Python async patterns. I’ll share the repo and API keys once we start, and I can run any extra diagnostics you request.