Can I run a Discord bot on AWS Lambda functions?

I’m working on creating a Discord bot and I’m curious about hosting it with AWS Lambda. I haven’t found many examples of people doing this successfully, so I’m not sure if it’s actually feasible.

My main concern is that Lambda functions don’t run continuously - they only activate when triggered. Discord bots typically need to maintain a persistent connection to receive messages and events in real time.

Has anyone managed to make this work? Are there specific patterns or workarounds for handling Discord’s WebSocket connections with serverless functions? I’m wondering if there are limitations I should know about before diving into this approach.

Any advice or examples would be really helpful since I’m trying to decide between Lambda and a traditional always-on server for my bot hosting.

Based on my experience, running a Discord bot on AWS Lambda has significant limitations due to its event-driven nature. While you can set up Lambda to handle specific commands or webhooks, you will miss out on real-time functionalities like message monitoring or event handling. The fundamental issue is that Discord bots require a constant connection for effective operation, something Lambda can’t provide due to its stateless framework. Transitioning to a traditional server setup, like an EC2 instance, may yield better results, as it allows for the persistent connection necessary for an active Discord bot.

i’ve been there too, trust me, lambda isn’t the way for discord bots. they need a constant connection to work well and lambda just doesn’t allow that. you’ll end up missing lots of msgs and it’ll lag hard. just go with a cheap vps, you’ll thank me later!

I tried this setup about six months ago and hit several roadblocks that made me switch to containers. The main issue isn’t just keeping connections alive - Lambda’s 15-minute timeout kills you. Even if you work around WebSockets using Discord’s HTTP interactions API, cold starts make your bot feel sluggish. Cost was another surprise. Lambda looks cheaper upfront, but an active Discord server triggers so many invocations that you’ll spend more than a small EC2 instance or VPS. I’d recommend AWS Fargate or ECS if you want to stick with AWS - you get persistent runtime without losing serverless benefits.