Basic ACD with Redis

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

  • Redis Enterprise: provides the distributed, fault-tolerant data structures to implement the core routing functionality.
  • REST API Servers, and Dispatchers: These are Python apps utilizing the redis-py client library to manage the Redis data structures for contact routing.
  • Load Balancers: This exercise uses an external load balancer (LB) to manage client connections to the Redis Enterprise cluster and the redundant REST API servers. While Redis Enterprise can manage client connection redundancy inherently through DNS, the LB model is also supported for production deployments as described here.
  • Redis Insight: This provides a user interface to Redis for data visualization. This is a no-cost GUI that can be a real aid for the developer to interact with data within Redis.
  • Admin Console: This is the Redis Enterprise GUI for administering the cluster and databases. It operates in a browser environment.
  • Redis Enterprise REST API: In addition to the admin console, Redis Enterprise exposes a REST API for administrative functions. The REST API is used here in start-up scripting to build the RE cluster.

Application-level Architecture

Article content


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.

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

  • Agent availability is established when they are placed into a sorted set with their entry timestamp.
  • Similarly, all contacts are initially placed in the queue (sorted set) with their associated timestamp.
  • Contacts are taken out of queue in a FIFO manner using the Redis BZPOPMIN command.
  • Agents are routed contacts via the Redis ZINTER of the availability sorted sets. The lowest-scoring Agent, the longest available, is targeted for the contact.


Source Code

https://github.com/redis-developer/basic-acd



I really miss working with you because of exactly things like this

Very informative Joey! Thanks for sharing.

To view or add a comment, sign in

More articles by Joey Whelan

Others also viewed

Explore content categories