SlideShare a Scribd company logo
8
Most read
20
Most read
21
Most read
FreeSWITCH as a
Microservice
vs.
What we are: an MVNO/MVNE running on
the Sprint Network
What we do: rapid development cycles and
constant iteration to be a different kind of
consumer cellular company.
Quickly: What is a microservices architecture?
Quickly: What is a microservices architecture?
• Monolithic
• Simpler architecture
• Generally confined to a single language
or framework
• Scaling Inefficient
• Depth of Knowledge Required (DOKR)
can lead to substantially increased
technical debt
• Microservices
• More complex
• Decoupled services allow for more rapid
development
• Increased scalability and fault tolerance
• Knowledge need not span multiple services
• Deployment is more complex but… simpler?
That Brings Us To…
Doesn’t Live in A Bubble
Doesn’t Live in A Bubble
• Billing
• Fraud Management
• Call Tracking & Analytics
• Performance Monitoring
• Call Quality Analysis
• Failover
• Realtime Multimodal Interaction (PSTN->WebRTC…)
Very different domains requiring very different processing
backends, language requirements, and service architectures
Simple Example
User Registration: mod_xml_curl
• Queries a remote API for registration information
• API uses business logic to decide which registrations
permissions to bestow
<binding name="directory">
<param name="gateway-url" value="https://dev.ringplus.net/endpoints" bindings="directory"/>
<param name="gateway-credentials" value="journey:foreigner" />
<param name="auth-scheme" value="basic"/>
</binding>
Works for dialplan, configuration, and phrases
Decouples SIP endpoint information
Easy migration to a mid-registrar like Kamailio
Registration
Microservice
Data
Store
HTTP
HTTP
(XML)
??? ???
if create_sip_endpoint
render :registration, status: :ok, formats: [:xml]
else
render xml: @sip_endpoint.errors, status: :unprocessable_entity
end
XML
RUBY
How About Something More
Fun
Here’s a little something.
Setting Preprocessor values: exec-set
<X-PRE-PROCESS cmd="exec-set" data="local_ip_v4 = ip addr show eth0 | awk '/inet /{print $2}' | head -n 1 | cut -d '/' -f 1"/>
Scenario: You’re starting a container and don’t know the IP
<X-PRE-PROCESS cmd="exec-set" data="internal_sip_port = echo $INTERNAL_SIP_PORT"/>
Scenario: You’re big into 12-Factor and are using lots of ENV variables
<X-PRE-PROCESS cmd="exec-set" data="rtp_start_port = /etc/freeswitch/rtp_ports_based_on_env
Scenario: It’s complicated, man. I need some real logic processing.
Go routine that queries a service to retrieve the public RTP ports for this container.
That service also opens/maps firewall and NAT ports correctly, or can really do anything.
Talking To FreeSWITCH Is Easy
Many choices of built-in modules and 3rd party libraries
• Ruby: Adhearsion (https://github.com/adhearsion/adhearsion)
• JavaScript: https://github.com/shimaore/esl
• Go: https://github.com/0x19/goesl
• Python: Python ESL
• mod_xml_rpc
• mod_verto
• etc…
What About Push?
This Sounds Complex.
Can we make this easier?
Let’s Talk About One Way To Go
• You may have heard me talk about this last year. I’m still talking about it.
• Containers should be single-process, no durable storage, ephemeral little
creatures
• Lightweight and distributable containers
• Scalability due to built in resilience and orchestration layers
• Higher packing density than virtual machines due to shared libs
Docker
DOCKER NETWORKING….
IT’S GOTTEN BETTER!
Docker Networking
• Docker 1.12 (June) allows for easy, multi-hostVXLAN routing
• Easily scale containers across nodes
• Built in state reconciliation for resilient deployments
• Orchestration is built into Docker Engine
• Includes auto-load balancing of inbound requests to multiple containers utilizing in-
kernel Linux IPVS, automaticTLS generation, and a free basket of kittens
Note: Docker is still a moving target.

• Documentation
• Best Practices
• Service Integration/Discovery
Practical Use Case
Scaling The Business Logic
Using Adhearsion for your dialplan.
- We use it for ease and rapidity of development
- Can leverage the Ruby ecosystem for gems
Problem: Ruby MRI is locked to a single CPU, so can become CPU bound
Solution: JRuby(?)
Problem Redux: Call volume on a particular node is exceeding CPU capacity due to
amazingly wonderful consumer adoption (Pokémon Go Syndrome)
Solution: Scale nodes
• FreeSWITCH is rarely the blocker but can consume enough CPU to max out
• Adhearsion communicates with mod_rayo via XMPP - many clients, one server.
CPU BOUND
Save money on the weekends ya’ll!
Scaling The Business Logic
Using Adhearsion for your dialplan.
- We use it for ease and rapidity of development
- Can leverage the Ruby ecosystem for gems
Problem: Ruby MRI is locked to a single CPU, so can become CPU bound
Solution: JRuby
Problem Redux: Call volume on a particular node is exceeding CPU capacity due to
amazingly wonderful consumer adoption (Pokémon Go Syndrome)
Solution: Scale nodes
• FreeSWITCH is rarely the blocker but can consume enough CPU to max out
• Adhearsion communicates with mod_rayo via XMPP - many clients, one server.
root@adhearsion-swarm-01:~# docker service ls
ID            NAME   REPLICAS  IMAGE                      COMMAND
ec23ck911hgc  adhearsion    20/20   ringplus/adhearsion:latest
28ght39gvfce  freeswitch   1/1       ringplus/freeswitch_v1.6:latest
root@adhearsion-swarm-01:~# docker service scale adhearsion=20
adhesion scaled to 20
FreeSWITCH
Adhearsion
NYC Datacenter
Adhearsion + FreeSWITCH
Spike Condition with DockerAdhearsion
DigitalOcean
NYC-1
NYC Datacenter
Kamailio
• Host monitoring detects low-CPU condition on Node 1
• collectd container
• Active call monitoring
• Calls Ansible to spin up a new DO container
• Adhearsion images pulled from Docker repo
• Start containers with overlay network and information on parent
FS container
• Quiesce Adhearsion on affected system
• Gracefully shutdown
• Update Kamailio MySQL DB with new dispatcher information if
FreeSWITCH scaling is necessary.
FreeSWITCH Joins
A Bunch of Microservices
FreeSWITCH
Static Assets
Voicemails
IVR
AdhearsionKafka
ELK
S3 / Gluster
Fraud API
Kafka Consumer
Billing API
Redis
Logs
WAL-E Backups
Postgres
HTTP/S, HTTPS, XMPP, XML, Go, Ruby, Elixer
RBT
Selection API
User API
NO MAGIC PILL YET.

STILL REQUIRES DEV, OPS, DEVOPS, MANAGEMENT

COMPLEXITY
Finals Thoughts & Bon Mots
• If you can help it, don’t start with microservices unless you have a team willing and able.
• Do build your monolithic app with an eye toward breaking it apart.
• Consider that you’ll eventually need to scale one part, but not others.
• Follow a Services or Operations pattern to development - make them as independent
as possible to facilitate eventual decoupling.
• Do think of your FreeSWITCH andVoIP infrastructure as smaller services.
• Consider your business case: Instead of running one 10k channel FreeSWITCH, why not
run 100 100-channel FreeSWITCH instances?
Evan McGee
@startledmarmot 

evan@ringplus.net

More Related Content

PDF
Introduction to FreeSWITCH
PPTX
The First 2 Steps to the Epiphany: Customer Discovery, Customer Validation an...
PDF
Trillion Dollar Coach Book (Bill Campbell)
PDF
A Playbook for Achieving Product-Market Fit
PDF
Art of thinking clearly
PPTX
Introduction to Node-RED
PDF
Docker in real life
PPTX
Diabetes Mellitus
Introduction to FreeSWITCH
The First 2 Steps to the Epiphany: Customer Discovery, Customer Validation an...
Trillion Dollar Coach Book (Bill Campbell)
A Playbook for Achieving Product-Market Fit
Art of thinking clearly
Introduction to Node-RED
Docker in real life
Diabetes Mellitus

What's hot (20)

PDF
FreeSWITCH on Docker
PDF
Scaling FreeSWITCH Performance
PDF
SIP Testing with FreeSWITCH
PPTX
FreeSWITCH as a Kickass SBC
PDF
Media Handling in FreeSWITCH
PDF
Kamailio, FreeSWITCH, and You
PDF
rtpengine and kamailio - or how to simulate calls at scale
PDF
SIP Attack Handling (Kamailio World 2021)
PDF
FreeSWITCH Cluster by K8s
PDF
Continuous Integration and Kamailio
PDF
An SFU/MCU integration for heterogeneous environments
ODP
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGI
PDF
IT Automation with Ansible
ODP
Using Asterisk and Kamailio for Reliable, Scalable and Secure Communication S...
PDF
FreeSWITCH on Docker
PDF
Kamailio on Docker
PPTX
Message queues
PPTX
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
PDF
Kamailio with Docker and Kubernetes
PDF
Tutorial WiFi driver code - Opening Nuts and Bolts of Linux WiFi Subsystem
FreeSWITCH on Docker
Scaling FreeSWITCH Performance
SIP Testing with FreeSWITCH
FreeSWITCH as a Kickass SBC
Media Handling in FreeSWITCH
Kamailio, FreeSWITCH, and You
rtpengine and kamailio - or how to simulate calls at scale
SIP Attack Handling (Kamailio World 2021)
FreeSWITCH Cluster by K8s
Continuous Integration and Kamailio
An SFU/MCU integration for heterogeneous environments
Phpconf 2013 - Agile Telephony Applications with PAMI and PAGI
IT Automation with Ansible
Using Asterisk and Kamailio for Reliable, Scalable and Secure Communication S...
FreeSWITCH on Docker
Kamailio on Docker
Message queues
Designing Apps for Runtime Fabric: Logging, Monitoring & Object Store Persist...
Kamailio with Docker and Kubernetes
Tutorial WiFi driver code - Opening Nuts and Bolts of Linux WiFi Subsystem
Ad

Similar to FreeSWITCH as a Microservice (20)

PPTX
Zoo keeper in the wild
PPTX
Node.js meetup at Palo Alto Networks Tel Aviv
PPTX
Understanding and deploying Network Virtualization
PPTX
Docker Swarm secrets for creating great FIWARE platforms
PDF
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
PDF
How to run a bank on Apache CloudStack
PDF
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
PDF
Latest (storage IO) patterns for cloud-native applications
PDF
Introduction to Apache Mesos and DC/OS
PDF
Orchestrating Linux Containers while tolerating failures
PPTX
Neutron scaling
PDF
Docker Introduction
PPTX
Practice of large Hadoop cluster in China Mobile
PDF
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
PDF
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
PPTX
Cont0519
PPTX
Dragonflow Austin Summit Talk
PPTX
Planning to Fail #phpuk13
PDF
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDN
PPTX
Docker & Daily DevOps
Zoo keeper in the wild
Node.js meetup at Palo Alto Networks Tel Aviv
Understanding and deploying Network Virtualization
Docker Swarm secrets for creating great FIWARE platforms
FIWARE Tech Summit - Docker Swarm Secrets for Creating Great FIWARE Platforms
How to run a bank on Apache CloudStack
What You Should Know About WebLogic Server 12c (12.2.1.2) #oow2015 #otntour2...
Latest (storage IO) patterns for cloud-native applications
Introduction to Apache Mesos and DC/OS
Orchestrating Linux Containers while tolerating failures
Neutron scaling
Docker Introduction
Practice of large Hadoop cluster in China Mobile
The Good, the Bad and the Ugly of Migrating Hundreds of Legacy Applications ...
Migrating Hundreds of Legacy Applications to Kubernetes - The Good, the Bad, ...
Cont0519
Dragonflow Austin Summit Talk
Planning to Fail #phpuk13
Tech Tutorial by Vikram Dham: Let's build MPLS router using SDN
Docker & Daily DevOps
Ad

Recently uploaded (20)

PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Empathic Computing: Creating Shared Understanding
PPTX
MYSQL Presentation for SQL database connectivity
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Review of recent advances in non-invasive hemoglobin estimation
PDF
KodekX | Application Modernization Development
PDF
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PPTX
Cloud computing and distributed systems.
PDF
The Rise and Fall of 3GPP – Time for a Sabbatical?
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
PDF
Spectral efficient network and resource selection model in 5G networks
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Approach and Philosophy of On baking technology
Empathic Computing: Creating Shared Understanding
MYSQL Presentation for SQL database connectivity
The AUB Centre for AI in Media Proposal.docx
Review of recent advances in non-invasive hemoglobin estimation
KodekX | Application Modernization Development
Shreyas Phanse Resume: Experienced Backend Engineer | Java • Spring Boot • Ka...
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Building Integrated photovoltaic BIPV_UPV.pdf
Electronic commerce courselecture one. Pdf
Per capita expenditure prediction using model stacking based on satellite ima...
Cloud computing and distributed systems.
The Rise and Fall of 3GPP – Time for a Sabbatical?
Mobile App Security Testing_ A Comprehensive Guide.pdf
Bridging biosciences and deep learning for revolutionary discoveries: a compr...
Spectral efficient network and resource selection model in 5G networks
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication

FreeSWITCH as a Microservice

  • 2. What we are: an MVNO/MVNE running on the Sprint Network What we do: rapid development cycles and constant iteration to be a different kind of consumer cellular company.
  • 3. Quickly: What is a microservices architecture?
  • 4. Quickly: What is a microservices architecture? • Monolithic • Simpler architecture • Generally confined to a single language or framework • Scaling Inefficient • Depth of Knowledge Required (DOKR) can lead to substantially increased technical debt • Microservices • More complex • Decoupled services allow for more rapid development • Increased scalability and fault tolerance • Knowledge need not span multiple services • Deployment is more complex but… simpler?
  • 6. Doesn’t Live in A Bubble
  • 7. Doesn’t Live in A Bubble • Billing • Fraud Management • Call Tracking & Analytics • Performance Monitoring • Call Quality Analysis • Failover • Realtime Multimodal Interaction (PSTN->WebRTC…) Very different domains requiring very different processing backends, language requirements, and service architectures
  • 8. Simple Example User Registration: mod_xml_curl • Queries a remote API for registration information • API uses business logic to decide which registrations permissions to bestow <binding name="directory"> <param name="gateway-url" value="https://dev.ringplus.net/endpoints" bindings="directory"/> <param name="gateway-credentials" value="journey:foreigner" /> <param name="auth-scheme" value="basic"/> </binding> Works for dialplan, configuration, and phrases Decouples SIP endpoint information Easy migration to a mid-registrar like Kamailio Registration Microservice Data Store HTTP HTTP (XML) ??? ??? if create_sip_endpoint render :registration, status: :ok, formats: [:xml] else render xml: @sip_endpoint.errors, status: :unprocessable_entity end XML RUBY
  • 10. Here’s a little something. Setting Preprocessor values: exec-set <X-PRE-PROCESS cmd="exec-set" data="local_ip_v4 = ip addr show eth0 | awk '/inet /{print $2}' | head -n 1 | cut -d '/' -f 1"/> Scenario: You’re starting a container and don’t know the IP <X-PRE-PROCESS cmd="exec-set" data="internal_sip_port = echo $INTERNAL_SIP_PORT"/> Scenario: You’re big into 12-Factor and are using lots of ENV variables <X-PRE-PROCESS cmd="exec-set" data="rtp_start_port = /etc/freeswitch/rtp_ports_based_on_env Scenario: It’s complicated, man. I need some real logic processing. Go routine that queries a service to retrieve the public RTP ports for this container. That service also opens/maps firewall and NAT ports correctly, or can really do anything.
  • 11. Talking To FreeSWITCH Is Easy Many choices of built-in modules and 3rd party libraries • Ruby: Adhearsion (https://github.com/adhearsion/adhearsion) • JavaScript: https://github.com/shimaore/esl • Go: https://github.com/0x19/goesl • Python: Python ESL • mod_xml_rpc • mod_verto • etc… What About Push?
  • 12. This Sounds Complex. Can we make this easier? Let’s Talk About One Way To Go
  • 13. • You may have heard me talk about this last year. I’m still talking about it. • Containers should be single-process, no durable storage, ephemeral little creatures • Lightweight and distributable containers • Scalability due to built in resilience and orchestration layers • Higher packing density than virtual machines due to shared libs Docker
  • 15. Docker Networking • Docker 1.12 (June) allows for easy, multi-hostVXLAN routing • Easily scale containers across nodes • Built in state reconciliation for resilient deployments • Orchestration is built into Docker Engine • Includes auto-load balancing of inbound requests to multiple containers utilizing in- kernel Linux IPVS, automaticTLS generation, and a free basket of kittens Note: Docker is still a moving target.
 • Documentation • Best Practices • Service Integration/Discovery
  • 17. Scaling The Business Logic Using Adhearsion for your dialplan. - We use it for ease and rapidity of development - Can leverage the Ruby ecosystem for gems Problem: Ruby MRI is locked to a single CPU, so can become CPU bound Solution: JRuby(?) Problem Redux: Call volume on a particular node is exceeding CPU capacity due to amazingly wonderful consumer adoption (Pokémon Go Syndrome) Solution: Scale nodes • FreeSWITCH is rarely the blocker but can consume enough CPU to max out • Adhearsion communicates with mod_rayo via XMPP - many clients, one server.
  • 18. CPU BOUND Save money on the weekends ya’ll!
  • 19. Scaling The Business Logic Using Adhearsion for your dialplan. - We use it for ease and rapidity of development - Can leverage the Ruby ecosystem for gems Problem: Ruby MRI is locked to a single CPU, so can become CPU bound Solution: JRuby Problem Redux: Call volume on a particular node is exceeding CPU capacity due to amazingly wonderful consumer adoption (Pokémon Go Syndrome) Solution: Scale nodes • FreeSWITCH is rarely the blocker but can consume enough CPU to max out • Adhearsion communicates with mod_rayo via XMPP - many clients, one server. root@adhearsion-swarm-01:~# docker service ls ID            NAME   REPLICAS  IMAGE                      COMMAND ec23ck911hgc  adhearsion    20/20   ringplus/adhearsion:latest 28ght39gvfce  freeswitch   1/1       ringplus/freeswitch_v1.6:latest root@adhearsion-swarm-01:~# docker service scale adhearsion=20 adhesion scaled to 20
  • 20. FreeSWITCH Adhearsion NYC Datacenter Adhearsion + FreeSWITCH Spike Condition with DockerAdhearsion DigitalOcean NYC-1 NYC Datacenter Kamailio • Host monitoring detects low-CPU condition on Node 1 • collectd container • Active call monitoring • Calls Ansible to spin up a new DO container • Adhearsion images pulled from Docker repo • Start containers with overlay network and information on parent FS container • Quiesce Adhearsion on affected system • Gracefully shutdown • Update Kamailio MySQL DB with new dispatcher information if FreeSWITCH scaling is necessary.
  • 21. FreeSWITCH Joins A Bunch of Microservices FreeSWITCH Static Assets Voicemails IVR AdhearsionKafka ELK S3 / Gluster Fraud API Kafka Consumer Billing API Redis Logs WAL-E Backups Postgres HTTP/S, HTTPS, XMPP, XML, Go, Ruby, Elixer RBT Selection API User API
  • 22. NO MAGIC PILL YET.
 STILL REQUIRES DEV, OPS, DEVOPS, MANAGEMENT
 COMPLEXITY
  • 23. Finals Thoughts & Bon Mots • If you can help it, don’t start with microservices unless you have a team willing and able. • Do build your monolithic app with an eye toward breaking it apart. • Consider that you’ll eventually need to scale one part, but not others. • Follow a Services or Operations pattern to development - make them as independent as possible to facilitate eventual decoupling. • Do think of your FreeSWITCH andVoIP infrastructure as smaller services. • Consider your business case: Instead of running one 10k channel FreeSWITCH, why not run 100 100-channel FreeSWITCH instances?