The Simplest Way to Make Apache Thrift and Cloud Run Work Like They Should

Published
Length
3 min read

Luis Felipe Dias

All posts

You can run Apache Thrift and Cloud Run together by wrapping Thrift calls in HTTP. This setup lets serverless containers exchange fast binary data across languages. Teams use this pair to link legacy backend apps with modern cloud services. Thrift defines the data types and service contracts in one shared file. Cloud Run takes that service, packs it in a container, and scales it up or down. You get strict data types and fast network calls without managing servers. How apache thrift and cloud

Your coding agents run with your access.

Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.

You can run Apache Thrift and Cloud Run together by wrapping Thrift calls in HTTP. This setup lets serverless containers exchange fast binary data across languages.

Teams use this pair to link legacy backend apps with modern cloud services. Thrift defines the data types and service contracts in one shared file. Cloud Run takes that service, packs it in a container, and scales it up or down. You get strict data types and fast network calls without managing servers.

How apache thrift and cloud run handle identity and data

Data flow between apache thrift and cloud run relies on HTTP transport layers. Cloud Run expects incoming traffic to use standard web protocols or gRPC. Raw TCP sockets do not work directly on this serverless platform. You must set up your Thrift server to read binary payloads over HTTP requests.

The client app packs the Thrift message and puts it in an HTTP POST body. Next, the client gets a signed identity token from Google Cloud IAM. It attaches this token to the request header and sends the call. Cloud Run checks the token before the container ever sees the traffic.

Once the check passes, the platform routes the payload to your running container. The Thrift server inside the container reads the binary body and runs the logic. It then sends the binary response back through the same HTTP path. This flow keeps data compact while using standard cloud security checks.

Common failure modes and how to scope roles

Many teams fail by using one shared service account for all containers. When every app uses the same identity, any service can call any other service. A bug or breach in one container puts the whole system at risk. Broad tokens also make it impossible to see which app made a specific call.

Another common issue is leaving services open to public internet traffic by mistake. Teams sometimes turn off platform identity checks to fix quick connection errors during testing. This leaves your binary endpoints exposed to anyone who finds the URL. Also, binary payloads hide request details from standard web logs. You might see a request hit the server, but you cannot see the method name.

End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

You can fix these risks by giving each Cloud Run service its own service account. Grant the invoker role only to the specific callers that need it. Set your ingress rules to allow internal traffic only when public access is not needed. Add structured logging inside your Thrift handler to record the caller identity and method name. If your handler processes sensitive data, add masking to rewrite emails or card numbers in logs.

Managing network paths and container lifecycles

Serverless containers spin up and shut down based on incoming request load. Thrift clients often assume a server stays up forever and holds open sockets. If a client caches a dead socket, the next remote call will fail. You need to set up short timeouts and connection pools on the client side.

Keep your container startup time fast so cold starts do not break client timeouts. Load only the libraries your Thrift handler needs to process the current call. When the container scales to zero, stateless HTTP transport ensures the next request starts clean. Test your retry logic under load to make sure dropped calls recover fast.

Check database and API queries on the wire

Identity tools, roles, and network rules decide who opens a session. Setup alone cannot check what each query does or mask sensitive values in a response once a session starts. When workflows touch Postgres, MySQL, SQL Server, MongoDB, ClickHouse, Kubernetes APIs, SSH, or internal HTTP APIs, hoop.dev runs beside those services as an open-source proxy, a sidecar for your Postgres or API. It inspects requests coming in and results going back on the wire.

Your login details and client tools stay as they are while hoop.dev guardrails refuse bad deletes or drops before they run. On responses, hoop.dev data masking rewrites matched sensitive values in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and writes every query and decision to an audit trail that generates evidence for HIPAA, GDPR, and PCI DSS. See the source on GitHub.

Frequently asked questions

Can Cloud Run handle raw TCP traffic from Apache Thrift?

No, Cloud Run only accepts HTTP, HTTPS, HTTP/2, and WebSockets traffic. You must use the Thrift HTTP transport mode to send binary payloads over web requests.

How do services log in to call a private Cloud Run endpoint?

The calling app requests an OIDC token from the Google Cloud metadata server. It places this token in the authorization header of the Thrift HTTP client.

How do we prevent cold starts from breaking Thrift client timeouts?

Set a minimum instance count on your service so one container always stays warm. You should also set short client timeouts with automatic retries for failed calls.

The query runs. The emails stay hidden.