GCP Cloud Functions: Latency when fetching regchecker API outbound

Hello Google Developers Community,

We are currently running a serverless microservice pipeline hosted on Google Cloud Functions (Node.js 18 runtime) for a UK automotive management app.

When a user triggers a vehicle inspection workflow, the Cloud Function fires an outbound HTTPS GET request to an external UK vehicle lookup API (Reg Checker) to retrieve MOT history records, tax expiry dates, and engine specs before saving the output to Cloud Firestore.

System Architecture and GCP Setup:

  • Data Endpoint: regchecker.co.uk

  • Mechanism: Cloud Firestore Trigger → GCP Cloud Function → HTTPS Fetch ([``https://regchecker.co.uk/?vrn=``](``https://regchecker.co.uk/?vrn=``)...) → Parse JSON → Update Firestore Document.

  • Software Environment: Node.js 18 / Google Cloud Functions Gen 2.

Technical Issue and Query:

  1. GCP Outbound Socket Latency: Intermittently, when making outbound REST calls to Reg Checker inside the GCP Cloud Function execution instance, the network connection delays by over 4000ms, causing function execution timeouts and cold-start spikes.

  2. JSON Data Array Memory Buffer: Parsing returned multi-year MOT advisory arrays inside the function instance occasionally causes temporary memory allocation spikes on default 256MB function tiers.

Troubleshooting Steps Taken:

  • Confirmed that backend query speeds directly on regchecker.co.uk execute under 200ms when tested independently outside the Google Cloud environment.

  • Increased function memory allocation to 512MB and enabled keep-alive HTTP agents, which reduced cold-start lag but didn’t fully resolve peak outbound socket delays.

Has anyone experienced execution stalls or socket delays when connecting external REST APIs to Google Cloud Functions or Firebase webhooks? Any recommended keep-alive or connection pooling patterns?

Thanks in advance!