Can we run php in worker?

Wait a moment, no need to get angry to create a simple subdomain, it’s a few letters and a click. Yes you need to do it, but what could be the issue here?

Matteo,

After this above fiasco, I am really circumspect with every option I touch on cloudflare. Creating a subdomain just to use a service seems a big step.

It really isn’t, it’s a simple subdomain they use to attach the subscription to since it’s per account, not per zone. It’s like if you added a new domain and enable Workers there with a lot less things to do.

1 Like

Matteo,

Any such limits on paid subscriptions?

Not that I know of, not sure if there extremely high bounds. Surely not 1000/10 minutes.

Can we enable rocket loader for this script (created by worker) as well?

No, there is no need for it. It doesn’t run on the user’s browser. It runs while the request to the server is in progress. It is in between there.

Even paid version has limits.

Yeah, of course it has memory and CPU limits, that can’t be left unlimited. CPU limits especially are state though.

Every cloud functions provider has these limits, they still have to run servers behind the various Workers.

I’m on the paid plan and have done load testing of ~10 000 requests in 15 seconds (~666/req/s).

Of which all succeeded and this was the largest test the load system could do, it would basically scale infinitely.

Yeah, but also npmjs.com runs on Workers. They do a whole lot more than 600 reqs/sec. On the paid plan there are no limits (up to the total bandwidth CF supports, but 30Tbps would be so much that he wouldn’t be using CF at all).

Matteo,

There are limits in worker paid plan.

An individual Worker script may consume up to:

  • 5-50 milliseconds CPU time per request, depending on Cloudflare Plan
  • 128MB memory at any given time

That is obvious, did you really expect unlimited CPU time and/or unlimited RAM usage in 180 locations for .0000005$/execution?

The current limits are 50ms CPU time (not a hard limit, it will allow some requests to go slightly above sometimes) and 128MBs RAM usage.

Matteo,

My problem is not limit but cloudflare is not intimating when those limit start getting hit, that is where huge problem arise.

Is not intimating? What does that mean?

Those limits I believe would be handled via the event.passThroughOnException() option.

you mean replacing event.respondWith(blockCountries(event.request)) with
event.passThroughOnException(blockCountries(event.request))

My point was does cloudflare dashboard inform anywhere when they start limiting requests?

Absolutely no.

Read the previous posts and the documentation:


Yes they do, in the workers analytics the tell you how many succeed or not.

Matteo,

I have less knowledge of worker programming.

According to the documentation which I understand

addEventListener('fetch', event => {
  event.respondWith(blockCountries(event.request))
})

with

addEventListener('fetch', event => {
  event.PassThroughOnException(blockCountries(event.request))
})

Am I not right here?

addEventListener('fetch', event => {
  event.passThroughOnException()
  event.respondWith(blockCountries(event.request))
})

or the last code is correct?

Last code is correct.

1 Like

Thanks Matteo

1 Like