Can anyone tell how a developer will use workers?

What kind of things developers can perform from Cloudflare workers? I have gone through that we can use slackbots, todo etc…these things we can do without workers then why to use such app/functions using Cloudflare workers?

There is no golden solution - there’s use-cases where getting a dedicated compute instance from somewhere like AWS or DigitalOcean will be better, and use-cases where serverless solutions will be better.

Workers are global - your script is deployed globally, so someone visiting your site in Japan will reach your Worker in a Japan colo whereas someone visiting your site in Canada will reach your Worker in a Canada colo.

There’s no worries of your infrastructure, or maintaining Docker images, etc - you deploy code and the runtime/infrastructure is handled by Cloudflare. That’s a benefit to most - and to some, it’s a disadvantage that they can’t tinker with it as much as they’d like.

There is no one answer for or against serverless - it scales well, but Workers are stateless so you won’t have any long-running instances (other than using Durable Objects and WebSockets I suppose, which costs $$$$$). You can store data in KV/Durable Objects/R2 but the Worker ‘compute’ is spun up and torn down extremely quickly.

Discord bots as an example - sure, you can host them on a VPS or you can have them on Workers. What’s the point in paying for compute just for your bot to show as ‘online’ when it’s doing nothing? You can host it on Workers (slash commands) and the Worker will only be active when it receives a payload (i.e heartbeat or user interaction).

Will it work for all Discord bots? No - but that’s a recurring theme. There is no ‘Workers are better’ or ‘AWS EC2 is better’. They have pros, they have cons and you’ll have to evaluate which one makes sense for your project.

3 Likes

Please also tell why to use Slackbot using workers. We can use Slack without workers. What’s the objective of using Slackbot using workers if we can chat/communicate in other ways like skype/teams/slack

I don’t follow.

Slackbot isn’t a chat platform - it’s a bot for Slack.

Add custom functionality, make it interact with your apps, add a message of the day - do whatever you want that a Slack bot can do.

1 Like

Excellent…you are clearing my concepts wisely. Now my next querry about Generate Youtube thumbnails with Workers and Cloudflare Image Resizing? What its mean? its mean just image compression or anything else ?