SlideShare a Scribd company logo
Fast and Easy Web Servers and APIs
in C++
SoCal Code Camp 10/11 November 2018
bit.ly/
rockncoder-2018-
svcc-cpp
Troy Miles
• Troy Miles
• Nearly 40 years of experience
• Coder, Author, Speaker
• LinkedIn Learning Author
• rockncoder@gmail.com
• @therockncoder

Agenda
• Why C++ and Docker?
• Crow Web Server
• Creating a build container
• Running locally
• Create a deploy container & Heroku
• Future Steps
Fast C++ Web Servers
Why C++?
• Faster startup time
• Handle more sessions simultaneously
• Need less servers, spend less money
• Modern C++ is awesome
C++ Web Frameworks
Framework Notes
Civetweb C/C++ embeddable web server
CppCMS Free High Perf. web development
Crow C++ micro web framework
Cutelyst C++ web framework built on top of Qt
Kore Ultra fast/flexible web server developed in C
libOnion library to create web servers in C
lwan experimental scalable high perf. HTTP server
QDjango web framework in C++ on top of Qt
TreeFrog hi-speed full stack web app. in C++ on Qt
Wt C++ library for developing web apps
C++ Web Frameworks
Framework Notes
Civetweb C/C++ embeddable web server
CppCMS Free High Perf. web development
Crow C++ micro web framework
Cutelyst C++ web framework built on top of Qt
Kore Ultra fast/flexible web server developed in C
libOnion library to create web servers in C
lwan experimental scalable high perf. HTTP server
QDjango web framework in C++ on top of Qt
TreeFrog hi-speed full stack web app. in C++ on Qt
Wt C++ library for developing web apps
Fast C++ Web Servers
Fast C++ Web Servers
Fast C++ Web Servers
Fast C++ Web Servers
Fast C++ Web Servers
Docker
• Operating system level virtualization
• Also know as containerization
• Initial release Mar 13, 2013
• Apache License 2.0
What Docker Brings?
• Solves development problems
• Solves deployment problems
Development Problems
• Polluting you dev box
• Installing the right libraries
Deployment Problems
• It doesn’t work in production
• Deploying too much stuff
• Knowing if it is safe to upgrade
Creating a volume
• docker run -v <host>:<container> -ti <image> bash
• -v: the volume option
• host:container
• -ti: terminal interactive mode
• image: the name of the docker image to launch
• bash: the name of the app to run
Opening a Port
• docker run -v <host>:<container> 

-p <host port>:<container port> 

-e PORT=8081 <image> <app to run>
• -e opens a port
• -e creates an environment variable
Viewing the examples
• docker build -t beastbox .
• docker run -v /beast:/usr/beast beatbox:latest bash
• docker ps
• docker cp <id>:/usr/src/beast_http_server ~/
Desktop/beast
Building the examples
• cd /usr/beast/beast_http_server
• mkdir build && cd build
• cmake ..
• make
Running an example
• examples/ex1_server/ex1_server
• ctrl-C to exit out of the server
Fixing the example
• Address must be 0.0.0.0
• Port should be read from an environment variable
• To rebuild, run make again
Exposing a Port
• -p 8080:80
• Translates the host port 8080 to the container port
80
• -e PORT:8080
• Creates an environment variable named PORT with
the value “8080” (a string)
Fast C++ Web Servers
Heroku
• Cloud Platform as a Service
• One of the first cloud platforms
• Available since June 2007
• Supports Ruby, Java, Node, Scala, Clojure, Python,
PHP, and Go
• Applications run in Dynos
Containerize It
• docker ps
• docker cp . <id>:/usr/beastweb
Deploy It
• heroku login
• heroku container:login
• heroku create
• docker build -t hello_beast .
• heroku container:push web -a floating-headland-31085
• heroku container:release web -a floating-headland-31085
• heroku open -a floating-headland-31085
Seeing the Logs
• heroku logs -a floating-headland-31085
Next Steps
• Better integration between my IDE and Docker

(Especially debugging)
• Adding HTML pages
• Adding WebSocket
Is Crow Dead?
• Last commit Dec. 27, 2017
• List of issues growing
• List of pull request growing too
Fast C++ Web Servers
Boost Beast
• Added to Boost in 2016
• Created by Vinnie Falco
• Header-only
• But low-level, not a server or a client
• https://www.youtube.com/watch?v=uJZgRcvPFwI
Beast HTTP Server
• Uses C++14 and Boost Beast
• Header-only
• Begun Jul 24, 2018
• Last commit Oct 8, 2018
• https://github.com/0xdead4ead/beast_http_server
Useful Links
• https://www.docker.com/
• https://www.heroku.com/home
• https://www.linkedin.com/learning
• https://github.com/0xdead4ead/beast_http_server
• https://github.com/ipkn/crow
• https://github.com/boostorg/beast
bit.ly/
rockncoder-2018-
svcc-cpp
Summary
• There are C++ web servers
• The payoff is fast initial response and more bang
for the buck
• Docker makes things easier, but debugging is
challenging
• You can deploy your containers to Heroku for free

More Related Content

What's hot (20)

PDF
I can't believe it's not a queue: Kafka and Spring
Joe Kutner
 
KEY
Wider than rails
Alexey Nayden
 
PPT
A Brief Introduce to WSGI
Mingli Yuan
 
PPTX
ILM - Pipeline in the cloud
Aaron Carey
 
PDF
Celery introduction
Ionel Mărieș Cristian
 
PDF
Python WSGI introduction
Ageeleshwar K
 
PDF
Apache Camel in the belly of the Docker whale
Henryk Konsek
 
PDF
Fighting Against Chaotically Separated Values with Embulk
Sadayuki Furuhashi
 
PDF
Google App Engine With Java And Groovy
Ken Kousen
 
PPTX
Ansible fest Presentation slides
Aaron Carey
 
PDF
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Tom Croucher
 
PDF
Mini Rails Framework
Aviandri Rivai
 
KEY
New Design of OneRing
Qiangning Hong
 
ODP
Introduction to Ansible
Knoldus Inc.
 
PDF
Automation with Ansible and Containers
Rodolfo Carvalho
 
PPTX
NodeJs
Orkhan Muradov
 
PDF
Ship your Scala code often and easy with Docker
Marcus Lönnberg
 
PPTX
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
PPTX
Packer, where DevOps begins
Jeff Hung
 
PPTX
Introduction to Packer and Suitcase: A Packer-based OS Image Build System
HubSpot Product Team
 
I can't believe it's not a queue: Kafka and Spring
Joe Kutner
 
Wider than rails
Alexey Nayden
 
A Brief Introduce to WSGI
Mingli Yuan
 
ILM - Pipeline in the cloud
Aaron Carey
 
Celery introduction
Ionel Mărieș Cristian
 
Python WSGI introduction
Ageeleshwar K
 
Apache Camel in the belly of the Docker whale
Henryk Konsek
 
Fighting Against Chaotically Separated Values with Embulk
Sadayuki Furuhashi
 
Google App Engine With Java And Groovy
Ken Kousen
 
Ansible fest Presentation slides
Aaron Carey
 
Using Node.js to Build Great Streaming Services - HTML5 Dev Conf
Tom Croucher
 
Mini Rails Framework
Aviandri Rivai
 
New Design of OneRing
Qiangning Hong
 
Introduction to Ansible
Knoldus Inc.
 
Automation with Ansible and Containers
Rodolfo Carvalho
 
Ship your Scala code often and easy with Docker
Marcus Lönnberg
 
An intro to Docker, Terraform, and Amazon ECS
Yevgeniy Brikman
 
Packer, where DevOps begins
Jeff Hung
 
Introduction to Packer and Suitcase: A Packer-based OS Image Build System
HubSpot Product Team
 

Similar to Fast C++ Web Servers (20)

PDF
Introduction to Docker and deployment and Azure
Jérôme Petazzoni
 
PDF
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
TheFamily
 
PDF
Introduction to Docker, December 2014 "Tour de France" Edition
Jérôme Petazzoni
 
PDF
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Jérôme Petazzoni
 
PDF
Introduction to Docker at the Azure Meet-up in New York
Jérôme Petazzoni
 
PDF
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Jérôme Petazzoni
 
PDF
Introduction to Docker at Glidewell Laboratories in Orange County
Jérôme Petazzoni
 
PDF
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Puja Abbassi
 
PDF
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
PDF
Docker Intro at the Google Developer Group and Google Cloud Platform Meet Up
Jérôme Petazzoni
 
PDF
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 
PDF
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Jérôme Petazzoni
 
PDF
Docker 101: An Introduction
POSSCON
 
PPTX
Docker - Demo on PHP Application deployment
Arun prasath
 
PDF
Docker From Scratch
Giacomo Vacca
 
PDF
Faster and Easier Software Development using Docker Platform
msyukor
 
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
PDF
Présentation de Docker
Proto204
 
PPTX
Docker for PHP Developers - Jetbrains
Chris Tankersley
 
PPTX
Java developer intro to environment management with vagrant puppet and docker
Getting value from IoT, Integration and Data Analytics
 
Introduction to Docker and deployment and Azure
Jérôme Petazzoni
 
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
TheFamily
 
Introduction to Docker, December 2014 "Tour de France" Edition
Jérôme Petazzoni
 
Docker 1 0 1 0 1: a Docker introduction, actualized for the stable release of...
Jérôme Petazzoni
 
Introduction to Docker at the Azure Meet-up in New York
Jérôme Petazzoni
 
Introduction to Docker, December 2014 "Tour de France" Bordeaux Special Edition
Jérôme Petazzoni
 
Introduction to Docker at Glidewell Laboratories in Orange County
Jérôme Petazzoni
 
Introduction to Docker and Linux Containers @ Cloud Computing Rhein Main
Puja Abbassi
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
Docker Intro at the Google Developer Group and Google Cloud Platform Meet Up
Jérôme Petazzoni
 
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Jérôme Petazzoni
 
Docker 101: An Introduction
POSSCON
 
Docker - Demo on PHP Application deployment
Arun prasath
 
Docker From Scratch
Giacomo Vacca
 
Faster and Easier Software Development using Docker Platform
msyukor
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
Présentation de Docker
Proto204
 
Docker for PHP Developers - Jetbrains
Chris Tankersley
 
Java developer intro to environment management with vagrant puppet and docker
Getting value from IoT, Integration and Data Analytics
 
Ad

More from Troy Miles (20)

PDF
Node Boot Camp
Troy Miles
 
PDF
AWS Lambda Function with Kotlin
Troy Miles
 
PDF
React Native One Day
Troy Miles
 
PDF
React Native Evening
Troy Miles
 
PDF
Intro to React
Troy Miles
 
PDF
Angular Application Testing
Troy Miles
 
PDF
ReactJS.NET
Troy Miles
 
PDF
What is Angular version 4?
Troy Miles
 
PDF
Angular Weekend
Troy Miles
 
PDF
From MEAN to the MERN Stack
Troy Miles
 
PDF
Functional Programming in JavaScript
Troy Miles
 
PDF
Functional Programming in Clojure
Troy Miles
 
PDF
MEAN Stack Warm-up
Troy Miles
 
PDF
The JavaScript You Wished You Knew
Troy Miles
 
PDF
Game Design and Development Workshop Day 1
Troy Miles
 
PDF
Build a Game in 60 minutes
Troy Miles
 
PDF
Quick & Dirty & MEAN
Troy Miles
 
PDF
A Quick Intro to ReactiveX
Troy Miles
 
PDF
JavaScript Foundations Day1
Troy Miles
 
PDF
AngularJS Beginner Day One
Troy Miles
 
Node Boot Camp
Troy Miles
 
AWS Lambda Function with Kotlin
Troy Miles
 
React Native One Day
Troy Miles
 
React Native Evening
Troy Miles
 
Intro to React
Troy Miles
 
Angular Application Testing
Troy Miles
 
ReactJS.NET
Troy Miles
 
What is Angular version 4?
Troy Miles
 
Angular Weekend
Troy Miles
 
From MEAN to the MERN Stack
Troy Miles
 
Functional Programming in JavaScript
Troy Miles
 
Functional Programming in Clojure
Troy Miles
 
MEAN Stack Warm-up
Troy Miles
 
The JavaScript You Wished You Knew
Troy Miles
 
Game Design and Development Workshop Day 1
Troy Miles
 
Build a Game in 60 minutes
Troy Miles
 
Quick & Dirty & MEAN
Troy Miles
 
A Quick Intro to ReactiveX
Troy Miles
 
JavaScript Foundations Day1
Troy Miles
 
AngularJS Beginner Day One
Troy Miles
 
Ad

Recently uploaded (20)

PPTX
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
PDF
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
PPTX
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
PDF
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
PPTX
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
PPTX
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
PDF
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
PDF
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
PDF
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
PPTX
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
PPTX
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
PDF
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
PDF
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
PPT
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
PPTX
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
PDF
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
PDF
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
PDF
Executive Business Intelligence Dashboards
vandeslie24
 
PDF
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
PPTX
Tally software_Introduction_Presentation
AditiBansal54083
 
Tally_Basic_Operations_Presentation.pptx
AditiBansal54083
 
Beyond Binaries: Understanding Diversity and Allyship in a Global Workplace -...
Imma Valls Bernaus
 
Fundamentals_of_Microservices_Architecture.pptx
MuhammadUzair504018
 
Powering GIS with FME and VertiGIS - Peak of Data & AI 2025
Safe Software
 
Comprehensive Guide: Shoviv Exchange to Office 365 Migration Tool 2025
Shoviv Software
 
Writing Better Code - Helping Developers make Decisions.pptx
Lorraine Steyn
 
Streamline Contractor Lifecycle- TECH EHS Solution
TECH EHS Solution
 
Mobile CMMS Solutions Empowering the Frontline Workforce
CryotosCMMSSoftware
 
GetOnCRM Speeds Up Agentforce 3 Deployment for Enterprise AI Wins.pdf
GetOnCRM Solutions
 
Perfecting XM Cloud for Multisite Setup.pptx
Ahmed Okour
 
Feb 2021 Cohesity first pitch presentation.pptx
enginsayin1
 
MiniTool Partition Wizard 12.8 Crack License Key LATEST
hashhshs786
 
Salesforce CRM Services.VALiNTRY360
VALiNTRY360
 
MergeSortfbsjbjsfk sdfik k
RafishaikIT02044
 
How Odoo Became a Game-Changer for an IT Company in Manufacturing ERP
SatishKumar2651
 
Understanding the Need for Systemic Change in Open Source Through Intersectio...
Imma Valls Bernaus
 
Unlock Efficiency with Insurance Policy Administration Systems
Insurance Tech Services
 
Executive Business Intelligence Dashboards
vandeslie24
 
Alexander Marshalov - How to use AI Assistants with your Monitoring system Q2...
VictoriaMetrics
 
Tally software_Introduction_Presentation
AditiBansal54083
 

Fast C++ Web Servers

  • 1. Fast and Easy Web Servers and APIs in C++ SoCal Code Camp 10/11 November 2018
  • 3. Troy Miles • Troy Miles • Nearly 40 years of experience • Coder, Author, Speaker • LinkedIn Learning Author • [email protected] • @therockncoder

  • 4. Agenda • Why C++ and Docker? • Crow Web Server • Creating a build container • Running locally • Create a deploy container & Heroku • Future Steps
  • 6. Why C++? • Faster startup time • Handle more sessions simultaneously • Need less servers, spend less money • Modern C++ is awesome
  • 7. C++ Web Frameworks Framework Notes Civetweb C/C++ embeddable web server CppCMS Free High Perf. web development Crow C++ micro web framework Cutelyst C++ web framework built on top of Qt Kore Ultra fast/flexible web server developed in C libOnion library to create web servers in C lwan experimental scalable high perf. HTTP server QDjango web framework in C++ on top of Qt TreeFrog hi-speed full stack web app. in C++ on Qt Wt C++ library for developing web apps
  • 8. C++ Web Frameworks Framework Notes Civetweb C/C++ embeddable web server CppCMS Free High Perf. web development Crow C++ micro web framework Cutelyst C++ web framework built on top of Qt Kore Ultra fast/flexible web server developed in C libOnion library to create web servers in C lwan experimental scalable high perf. HTTP server QDjango web framework in C++ on top of Qt TreeFrog hi-speed full stack web app. in C++ on Qt Wt C++ library for developing web apps
  • 14. Docker • Operating system level virtualization • Also know as containerization • Initial release Mar 13, 2013 • Apache License 2.0
  • 15. What Docker Brings? • Solves development problems • Solves deployment problems
  • 16. Development Problems • Polluting you dev box • Installing the right libraries
  • 17. Deployment Problems • It doesn’t work in production • Deploying too much stuff • Knowing if it is safe to upgrade
  • 18. Creating a volume • docker run -v <host>:<container> -ti <image> bash • -v: the volume option • host:container • -ti: terminal interactive mode • image: the name of the docker image to launch • bash: the name of the app to run
  • 19. Opening a Port • docker run -v <host>:<container> 
 -p <host port>:<container port> 
 -e PORT=8081 <image> <app to run> • -e opens a port • -e creates an environment variable
  • 20. Viewing the examples • docker build -t beastbox . • docker run -v /beast:/usr/beast beatbox:latest bash • docker ps • docker cp <id>:/usr/src/beast_http_server ~/ Desktop/beast
  • 21. Building the examples • cd /usr/beast/beast_http_server • mkdir build && cd build • cmake .. • make
  • 22. Running an example • examples/ex1_server/ex1_server • ctrl-C to exit out of the server
  • 23. Fixing the example • Address must be 0.0.0.0 • Port should be read from an environment variable • To rebuild, run make again
  • 24. Exposing a Port • -p 8080:80 • Translates the host port 8080 to the container port 80 • -e PORT:8080 • Creates an environment variable named PORT with the value “8080” (a string)
  • 26. Heroku • Cloud Platform as a Service • One of the first cloud platforms • Available since June 2007 • Supports Ruby, Java, Node, Scala, Clojure, Python, PHP, and Go • Applications run in Dynos
  • 27. Containerize It • docker ps • docker cp . <id>:/usr/beastweb
  • 28. Deploy It • heroku login • heroku container:login • heroku create • docker build -t hello_beast . • heroku container:push web -a floating-headland-31085 • heroku container:release web -a floating-headland-31085 • heroku open -a floating-headland-31085
  • 29. Seeing the Logs • heroku logs -a floating-headland-31085
  • 30. Next Steps • Better integration between my IDE and Docker
 (Especially debugging) • Adding HTML pages • Adding WebSocket
  • 31. Is Crow Dead? • Last commit Dec. 27, 2017 • List of issues growing • List of pull request growing too
  • 33. Boost Beast • Added to Boost in 2016 • Created by Vinnie Falco • Header-only • But low-level, not a server or a client • https://www.youtube.com/watch?v=uJZgRcvPFwI
  • 34. Beast HTTP Server • Uses C++14 and Boost Beast • Header-only • Begun Jul 24, 2018 • Last commit Oct 8, 2018 • https://github.com/0xdead4ead/beast_http_server
  • 35. Useful Links • https://www.docker.com/ • https://www.heroku.com/home • https://www.linkedin.com/learning • https://github.com/0xdead4ead/beast_http_server • https://github.com/ipkn/crow • https://github.com/boostorg/beast
  • 37. Summary • There are C++ web servers • The payoff is fast initial response and more bang for the buck • Docker makes things easier, but debugging is challenging • You can deploy your containers to Heroku for free