Basic ACD with Redis
Building a contact center router is deceivingly non-trivial. An enterprise-grade router has to manage much more than just the basic producer/consumer model of sending inbound contacts to agents. I'll demonstrate in this article how a basic ACD can be constructed entirely with Redis data structures and deployed in a distributed and fault-tolerant architecture. The concepts of multi-skilled agents, contacts, and queuing are all supported.
Overall Architecture
This exercise was designed to be operable on a laptop - albeit a fairly capable one. All components are deployed as containers within a Docker environment - including a three-node Redis Enterprise cluster. While production deployments of Redis Enterprise are not supported in Docker, containerized Redis Enterprise is supported in a Kubernetes setting as described here.
Components
Application-level Architecture
Components
HAProxy w/Keepalived: Two instances of HAProxy are deployed as containers. HAProxy provides load balancing and high availability for all components in the architectures. Those HAProxy containers include Keepalived to provide high availability for the HAProxy containers themselves. A VIP is exposed with Keepalived which is used for all client connections to the components.
FastAPI Servers: These are Python Docker containers deployed as multiple replicas via Docker Compose. HA is achieved for this component via HTTP load balancing from HAProxy. A REST API for interacting with the Redis data structures is exposed on these containers.
Dispatchers: These are also Python-based Docker containers deployed as multiple replicas for fault tolerance. They are providing the contact routing function via interaction with the FastAPI servers.
Simulator: This is a Python application that creates the contact center components (agents, skills, etc) and then generates a stream of contacts via the REST API.
Recommended by LinkedIn
Redis Data Structure Mappings
Contacts -> Redis JSON objects with JSON arrays to support multi-skill requirements for a contact.
Agents -> Redis JSON objects with arrays to support multi-skilled agents.
Skills -> Redis Sorted Sets are used to maintain availability queues for agents - per skill. An agent's time of becoming is used as their sorted set score to allow for Longest Available Agent (LAA) targetting logic.
Queue -> Redis Sorted Set is also used to implement a universal queue. Set members are the Redis keys to the JSON object representing contacts. Scores for set members their timestamp for entry to the queue. This allows use of inherent Redis Sorted Set functionality to implement multi-skill selection and first-in-first-out (FIFO) queue handling.
Routing
Source Code
I really miss working with you because of exactly things like this
Love the content
Very informative Joey! Thanks for sharing.