Rolando Andrade
Back to projects

Built in 2022

Unbanked Architecture Enhancements

Backend Architecture Improvements

Unbanked Architecture Enhancements preview

Webhook Subsystem. A socket strategy to communicate with partners that included its own alerting subsystem too. The main problem here was dealing with the load balancer. Improved the flows and event communication through the usage of bull jobs, assessment of the priorities, and optimizing the number of Redis connections.

At a fintech company, partner integrations run all night. If your payment provider sends a webhook at 3 AM and your system misses it, someone loses money. At Unbanked, partners expected live updates through sockets. Internal services had to react to outside events. And a load balancer sat in the middle, breaking everything.

The symptoms were familiar. Socket connections dropped at random. Events arrived late or never. Redis memory use jumped during peak hours. Alerting came last. We found out about failures when partners complained.

The architecture needed a full rethink.

Three systems, one goal

The project delivered three connected systems:

  1. A webhook subsystem that receives, validates and processes partner notifications reliably. A webhook is a message a partner’s server sends to ours when something happens.
  2. A socket strategy that keeps persistent connections with partners, even behind the load balancer.
  3. An alerting subsystem that tells us about failures before our partners do.

Each one solved a specific problem. Together, they changed how Unbanked talked to the outside world.

Sockets behind a load balancer

A load balancer spreads connections across several server instances. A socket connection, though, has state. Client A connects to Server 1. When Client A sends a message, it has to reach Server 1.

Our setup used sticky sessions based on IP addresses. That worked until it did not. Mobile clients changed IPs. Corporate networks rotated addresses. Connections landed on the wrong server.

The fix was Socket.IO’s adapter pattern, with Redis in the middle. Every server instance published events to Redis. Every instance subscribed to the channels it cared about. To reach a specific client, a server sent the message through Redis to all servers. The server holding that connection delivered it. It no longer mattered which server got the original request.

This pattern also let us scale out. We could add more servers behind the load balancer. They joined the Redis pub/sub on their own, with no configuration changes.

A queue in front of the work

Raw webhooks are unpredictable. A partner might send one event per second or a thousand. Processing one might take milliseconds or minutes. Without a buffer, you either drop events or overload your servers.

Bull queues gave us that buffer. Each incoming webhook hit a thin endpoint. We checked the signature, confirmed receipt and pushed the payload into a queue. The partner got its 200 OK response in milliseconds.

Behind the queue, workers processed events at a steady pace. We set priorities, so payment confirmations ranked above balance updates. Failed jobs went to a retry queue with exponential backoff, which waits longer after each failure. After too many failures, a job landed in a dead letter queue for a person to review.

A webhook gets a fast reply, then waits in a queue until a worker processes it.
A webhook gets a fast reply, then waits in a queue until a worker processes it.

The queue also solved the ordering problem. Some events depend on others. A refund event means nothing if the original payment has not been processed yet. Bull’s job dependencies let us chain related events together.

Too many Redis connections

Redis powered both the socket adapter and the job queues. That meant a lot of connections. Each worker needed its own. Each server instance needed some for pub/sub. The numbers added up fast.

During a traffic spike, we hit the Redis connection limit. The server logged errors and events stopped flowing. On the surface everything looked healthy. You only saw the problem when you checked Redis.

The fix was connection pooling with heavy reuse. We created shared pools for common operations. Reads shared one pool. Writes shared another. The socket adapter kept its own connections, because pub/sub needs subscriptions that stay open.

We also tuned the connection settings. Shorter idle timeouts closed unused connections sooner. Health checks caught dead connections before they caused trouble. Dashboards showed connection counts next to the usual metrics.

Alerts before complaints

Hearing about failures afterward was not good enough. The alerting system watched for specific patterns:

  • A webhook that failed three times in a row.
  • A socket connection that dropped and could not reconnect.
  • A queue that grew faster than the workers could empty it.

Each alert type had its own severity and channel. Payment failures went to Slack and PagerDuty. Queue backlogs started in Slack and escalated if they lasted. Connection issues went to our monitoring system first.

The alerting code lived next to the features it watched. When we added a new webhook type, we added its alerts in the same pull request. Coverage stayed complete without a separate alerting team.

What changed for partners

Partner complaints about missed events dropped to near zero. We could trace any webhook from arrival to final processing. Socket connections stayed stable, even during deployments. Redis memory use became predictable.

Future work got easier too. Adding a new partner meant defining its webhook format and its queue priority. The infrastructure handled the rest.


Backend architecture work rarely makes headlines. It decides whether your product works at scale. If you are dealing with unreliable integrations, unpredictable load or systems that fail silently, I would be happy to discuss approaches.

Interested in working together? Check out my services and pricing to see how we can collaborate on your next project. Let's Build