Hi, I´m deploying Permit PDP to GCP Cloud Run, and...
# permit-saas
r
Hi, I´m deploying Permit PDP to GCP Cloud Run, and is working fine. However after review metrics, I identify new instances are being created, even workload is low. I´m sharing graphs. Is there a way to optimize number of Cloud Runs PDP is creating ?
a
Hi @Roberto Macaotela, I'm an AI assistant for Permit.io. I'll analyze available sources and get back to you shortly.
Para optimizar el número de instancias de PDP en Cloud Run, la configuración clave es ajustar el Auto Scaling. (1) En la sección "Auto Scaling" de Cloud Run, configura el "Minimum number of instances" a 1. Esto asegurará que siempre haya al menos una instancia del PDP ejecutándose para evitar arranques en frío (cold starts) . La documentación explica que no queremos que las consultas de autorización y las solicitudes al PDP fallen o tomen mucho tiempo debido a los arranques en frío. Adicionalmente, hay una configuración importante para resolver problemas de terminación inesperada con Signal 6 (SIGABRT) en Cloud Run. Este problema ocurre porque la configuración de asignación de CPU de Cloud Run permite que los procesos de tareas en segundo plano, como el PDP, liberen recursos de CPU cuando están inactivos, resultando en la terminación del contenedor por CPU insuficiente. Para solucionarlo, se recomienda agregar la anotación
<http://run.googleapis.com/cpu-throttling|run.googleapis.com/cpu-throttling>: false
en la configuración YAML. El archivo YAML de configuración está disponible en el repositorio de GitHub de ejemplos de despliegue . Para ayudarte mejor con la optimización, ¿podrías compartir: 1. ¿Qué Workspace / Project / Env estás usando? 2. ¿Qué llamadas estás realizando (como código SDK o CURL) ? 3. ¿Qué versión del PDP estás ejecutando? 4. ¿Podrías compartir los logs relevantes de tu PDP?
To learn more, see the sources I considered: [[1] Deploying PDP on GCP Cloud Run](https://docs.permit.io/how-to/deploy/cloud-hosts/gcp-cloud-run)
o
Mmm, odd that the agent has responded in Spanish.
I'll ask our devops to offer more advice here
Also @Ask Inkeep can you reply again but in English
a
Thanks for tagging me @Or Weis. I'll look through relevant sources and get back to you shortly.
To optimize the number of PDP instances on Cloud Run, the key configuration is adjusting the Auto Scaling settings (1) . In the Cloud Run "Auto Scaling" section, set the "Minimum number of instances" to 1 . This ensures there's always at least one PDP instance running to avoid cold starts . The documentation explains that we don't want authorization queries and PDP requests to fail or take a long time due to cold starts . Additionally, there's an important configuration to resolve unexpected termination issues with Signal 6 (SIGABRT) in Cloud Run . This issue stems from Cloud Run's CPU allocation settings, which allow background task processes like the PDP to release CPU resources when idle, resulting in container termination due to insufficient CPU availability . To address this, add the
<http://run.googleapis.com/cpu-throttling|run.googleapis.com/cpu-throttling>: false
annotation in the YAML configuration . The YAML configuration file is available in the Deployments Github Repository . To help optimize further, could you share: 1. Which Workspace / Project / Env you're using 2. What calls you're performing (as SDK code or CURL) 3. Which PDP version you're running 4. Relevant logs from your PDP
To learn more, see the sources I considered: [[1] Deploying PDP on GCP Cloud Run](https://docs.permit.io/how-to/deploy/cloud-hosts/gcp-cloud-run)
e
Hi @Roberto Macaotela, Thanks for sharing the graphs! What you’re seeing is normal Cloud Run behavior, it briefly spins up extra instances during cold starts or right after a new deployment, even when traffic is low. To keep things smoother and avoid unnecessary scaling:
Copy code
gcloud run services update permit-pdp --region <REGION> \
  --concurrency=32 --min-instances=1 --max-instances=3
This keeps one instance warm (fewer cold starts), lets each instance handle multiple requests, and caps the maximum at three. After this change, you should see the instance count stay near one most of the time, with only short spikes during bursts or deploys. Let us know how it looks after applying this 🙂