Building a Serverless Laravel queue processor on GCP

Before you start

Be sure to read my previous article on how to use Pub/Sub as a Laravel Queue driver. I will assume you already have a Laravel project that populates a Pub/Sub topic and go from there.

Going serverless

You have a couple of options to link a Pub/Sub topic to other components. I will use Cloud Functions and Cloud Run which are both serverless products.

  • Node.js 10, 12 and 14
  • Python 3.7 and 3.8
  • Go 1.11 and 1.13
  • Java 11
  • .NET Core 3.1
  • Ruby 2.6 and 2.7
Trigger a cloud function
Cloud logging entry

Cloud Run queue workers

Migrating part of your code to other languages might be a deal breaker. Luckily, we have the option to run PHP Job code from our Laravel project on a serverless component: Cloud Run.

Connecting the pieces

Get the URL of your Cloud Run Instance and go to the Pub/Sub topic. Create a new subscription that pushes each Pub/Sub message to your Cloud Run service:

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alex De Smet

Alex De Smet

22 Followers

Senior Cloud Devops Engineer @vbridgebv. Former college teacher.