The Simplest Way to Make Google Pub/Sub and Haproxy Work Like They Should
Running google pub/sub and haproxy together routes cloud messages to your backend apps. Pub/Sub holds the event stream while HAProxy balances push traffic across healthy worker nodes. This setup keeps message processing fast and stops single servers from crashing under heavy load. Teams use it to link cloud queues with private data centers or Kubernetes clusters. How data and roles flow between google pub/sub and haproxy Pub/Sub sends messages to subscribers using either pull requests or pus
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.
Running google pub/sub and haproxy together routes cloud messages to your backend apps. Pub/Sub holds the event stream while HAProxy balances push traffic across healthy worker nodes.
This setup keeps message processing fast and stops single servers from crashing under heavy load. Teams use it to link cloud queues with private data centers or Kubernetes clusters.
How data and roles flow between google pub/sub and haproxy
Pub/Sub sends messages to subscribers using either pull requests or push webhooks. When you use push webhooks, Pub/Sub acts as a client and sends web requests out. HAProxy sits at the edge of your network and catches those incoming push requests.
First, Pub/Sub attaches a signed token to each push message it sends out. This token comes from a specific cloud service account that you set up. HAProxy receives the encrypted web traffic and checks the TLS certificate at the edge.
Next, HAProxy passes the request to a pool of internal worker apps. Your worker apps check the signed token to prove the message came from Google. If the token is valid, the app reads the message and returns a success code. HAProxy sends that success code back to Pub/Sub, which removes the message from the queue.
You can also run this flow in reverse for apps that publish messages. Internal apps send messages through HAProxy to reach the Google cloud endpoints. HAProxy controls the outbound traffic and prevents single apps from opening too many sockets.
Common failure modes and how to scope roles
Many teams make the mistake of sharing one cloud service account across all topics. If a bad actor steals that key, they can read or fake every message. Another common failure is using broad tokens that never expire on worker nodes.
Unlogged traffic also causes major blind spots during an outage or security audit. If HAProxy only logs basic network numbers, you will not know which topic failed. You also cannot see which worker node dropped the message or why it broke.
End-to-End Encryption + HAProxy Security: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
To fix identity risks, create one dedicated service account for each push subscription. Give that account the smallest role possible so it can only push to one place. Never give worker nodes full project rights when they only need to read one queue.
Lock down your network paths so HAProxy only accepts traffic from known cloud ranges. Set up mutual TLS or strict token checks before traffic reaches your core network. Turn on detailed request logging in HAProxy to record every status code and latency spike.
Managing worker health and sensitive payload data
Queue spikes can overwhelm backend apps if HAProxy routes traffic to slow servers. Set up active health checks in HAProxy so it tests each worker app often. When a worker slows down, HAProxy stops sending it new push messages right away.
Pub/Sub sees the failed delivery if all workers are busy and waits to retry. This natural backoff protects your database and backend systems from total failure during traffic bursts.
Event payloads often carry private user details like emails, phone numbers, or card numbers. If an engineer inspects raw queues or debug logs, those fields can leak out. Teams should use data masking tools that rewrite matched fields in results before anyone reads them.
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
Should I use Pub/Sub push or pull with HAProxy?
Use push subscriptions when you want HAProxy to balance incoming web requests across stateless workers. Use pull subscriptions when your internal workers need to control their own message reading speed.
How does HAProxy handle slow message workers?
HAProxy runs regular health checks and tracks how many requests each backend server handles. If a server hits its limit, HAProxy holds the request or sends it to another node.
How do we secure Pub/Sub push endpoints on HAProxy?
Require TLS encryption on the HAProxy frontend and turn on signed tokens in Pub/Sub. Have your edge or backend app check the token signature before processing any message body.
Related guides
In this post