SlideShare ist ein Scribd-Unternehmen logo
1 von 63
Downloaden Sie, um offline zu lesen
Eduardo Silva
@edsiper
eduardo@treasure-data.com
Eduardo Silva
●
Github & Twitter @edsiper
●
Personal Blog http://edsiper.linuxchile.cl
Treasure Data
●
Open Source Engineer
●
Fluentd / Fluent Bit http://github.com/fluent
Projects
●
Monkey HTTP Server http://monkey-project.com
●
Duda I/O http://duda.io
About Me
HTTP Everywhere
Use cases
●
Home Automation
●
Big Data
●
Data Collection
basically everywhere...
●
Internet of Things
●
Wearables
●
Automotive
Monkey HTTP Server
Monkey HTTP Server
Highlights
●
Event driven
●
Multi-thread
●
Zero copy strategy
●
Memory optimization
●
Secure
●
Optimized for Linux, but compatible with others.
●
Embedded Linux / Yocto
●
Open Source: Apache License v2.0
Monkey HTTP Server
Modular Design
●
mk_core: agnostic runtime for handling of strings,
memory, event loop, configuration reader, vectors
and utilities within others.
●
mk_server: TCP server, data streams, protocols,
plugins manager, scheduler and general runtime setup.
●
plugins: networking layer for I/O operations, stage
handlers and content handlers.
Architecture
Monkey HTTP Server
Architecture
Monkey HTTP Server
Master Process
●
Prepare the environment.
●
Read and process configuration.
●
Load plugins and initialize them.
●
Create a Scheduler instance.
●
All things required before joining
the event loop.
Monkey HTTP Server
Scheduler
●
Balancing mode / OS check:
●
Fair balancing
●
Shared TCP ports (SO_REUSEPORT)
●
Setup Listeners.
●
Create the event loop for each
worker.
●
Handle incoming connections.
Monkey HTTP Server
Scheduler mode: Fair balancing
●
One scheduler instance.
●
It accepts all connections.
●
Distribute to the less busy
worker.
●
Old fashion mechanism.
Monkey HTTP Server
Scheduler mode: Shared TCP ports
●
Scheduler handler, one per
worker.
●
Connections are distributed
by the Kernel.
●
High performance, less
contention.
●
SO_REUSEPORT
Monkey HTTP Server
Scheduler: Listeners
●
Bind a network address to
listen for connections.
●
TCP port
●
Associate Network I/O layer
handler plugin.
●
Associate protocol handler
for each connection.
Monkey HTTP Server
Workers
●
Each worker have one event loop.
●
Associate Listeners with connections.
●
Handle protocol operations based on
events notified.
●
Timeout connections.
●
Cleanup sessions.
Monkey HTTP Server
Workers: event loop
Plugins
Monkey HTTP Server
Plugins
●
Monkey core provides only basic
HTTP processing
●
Plugins provides interfaces for:
●
Network I/O operations
●
Security
●
Content Handling
●
HTTP Stages / Hooks
Monkey Plugins
Network Layer: I/O
●
Liana: Basic socket I/O handling, for
short plain sockets.
●
TLS: built on top of mbedTLS, provides
SSL and TLS encryption capabilities
when writing/reading data over sockets.
“Monkey core and content handling plugins are not
aware about how the network I/O is being handled,
unless they ask for”
Monkey Plugins
Plugins: stages
STAGE 10 Connection accepted.
STAGE 20 Request have been received.
STAGE 30 Content handler.
STAGE 40 Response completed.
STAGE 50 Connection closed.
Each stage represents a phase of an incoming request
cycle inside the server:
Monkey Plugins
Plugins: STAGE 10
Every time a connection is accepted by
the scheduler, the plugins associated with
this stage are triggered.
The security plugin mandril, hooks to this
stage and provides restrictions by IP.
Monkey Plugins
Plugins: STAGE 20
This stage triggers the plugins callbacks
every time a request have arrived
successfully to the server.
Monkey Plugins
Plugins: STAGE 30
Well known as the content handler, owns
the request and process a response. Some
plugins that works at this level are:
●
FastCGI
●
CGI
●
Directory Listing
●
Duda I/O
Monkey Plugins
Plugins: STAGE 40
Once a request have finished like
completed successfully or due to an
exception, this stage is triggered.
The logger plugin makes use of this stage
to make sure to register all kind of events.
Monkey Plugins
Plugins: STAGE 50
This stage triggers the associated
callbacks every time a TCP connection
is closed by a protocol, scheduler timeout
or due to any network anomaly found.
Monkey HTTP Server
Memory Handling
●
Just one memory allocation per TCP connection.
●
Jemalloc memory allocator built-in by default, if desired
it can be disabled at build time.
Monkey HTTP Server
System calls / Tweaks
●
sendfile(2) static content delivery
●
writev(2) write multiple buffers as an array (headers)
●
splice(2) move data between file descriptors (logger)
●
epoll(7) I/O event notification on Linux
●
kqueue(2) I/O event notification on OSX & BSD
●
accept4(2) accept connection and set option (non block)
●
TCP_CORK send only full packets (on-demand)
●
SO_REUSEPORT shared TCP ports (if available)
●
SOCK_NONBLOCK non-blocking sockets
Monkey HTTP Server
Clock thread: cached date
The server spawns a thread named clock. It basically
update a local memory buffer with a formatted version
of the current time. This info is mandatory in the response
header.
note: if you get 1000 request per second, you don't want
to do a string formatting 1000 times for the same time.
Monkey HTTP Server
Indented Configuration
Force people to use an indented format, avoid a
spaghetti configuration.
note: it works!, read Python code ;)
Monkey HTTP Server
Linux Kernel detection
If running on Linux, check the Kernel version and enable
some features if they are available, e.g:
●
TCP_FASTOPEN
●
SO_REUSEPORT
●
TCP_AUTOCORKING (currently disabled)
Monkey HTTP Server
Embedded Linux
●
Monkey is a Yocto compliant project and available through
meta-openembedded.
●
We distribute packages for Raspbian
Monkey HTTP Server
General features
●
HTTP/1.1
●
Virtual Hosts
●
IPv4 / IPv6
●
TLS/SSL
●
CGI
●
FastCGI
●
Directory Listing
●
Log Writer
●
Basic Authentication
HTTP/2.0
Monkey and HTTP/2.0
Status
●
Internals need some rewrite to start implementing
the new version of the protocol: done.
●
Listener must support multiple protocols: done.
●
HTTP/2.0 handshake and further spec: work in process.
The goal is to have a functional HTTP/2.0 version before
the end of this year. The hard part were to extend
the internals to start supporting all requirements.
Monkey
Roadmap
●
HTTP/2.0
●
Proxy reverse
●
Restore library mode
●
Co-routines
●
Logging Layer instead of plugin hooks.
●
URL rewrite support.
Web Services
Web Services
What do we usually expect
●
Lightweight ?
●
High Performance ?
●
Extensible ?
●
Scalabale ?
●
Secure ?
●
Web Services
A short story, facts:
●
Company X was developing an Apnea monitoring
product for in-house usage (2011).
●
Target device was a low cost ARM end device.
●
They develop their web service in Java.
●
When they ported the web service to the ARM device,
each HTTP request took a few seconds to reply =/ .
Web Services
Workarounds
●
Use a more expensive ARM device that Java supported
better ?
●
Pay $Oracle to improve Java for that specific ARM
architecture ?
●
Build the web service in a better language from scratch ?
Web Services
Almost write from scratch
●
Monkey was already optimized for ARM, it have an
extensible architecture.
●
Write a Monkey extension that provides a flexible and
easy C API to implement web services.
●
So a new project was born...
http://duda.io
Duda I/O
About
●
Duda is a scalable web services stack (made in C).
●
x86, x86_64 & ARM.
●
Open Source / Apache License v2.0 .
●
Target: high end production servers and Embedded Linux.
Duda I/O
Features
●
Event driven
●
Friendly C API / Objects
●
Co-routines
●
HTTP / HTTPS
●
WebSockets
●
JSON / MySQL / Redis / SQLite
●
Packages support
●
In-memory Key value store
●
much more!...
Duda I/O
Architecture
Duda I/O
Performance matters!
Duda I/O
Production ready
●
Big Data
●
Real Time Bidding
●
Home Automation
●
Mobile Backends
●
Etc...
Monkey and IoT
Internet of Things
Facts
●
IoT will grow to many billions of devices over the
next decade.
●
Now it's about device to device connectivity.
●
Different frameworks and protocols are emerging.
●
It needs Logging.
Internet of Things
Alliances
Vendors formed alliances to join forces and develop
generic software layers for their products:
Internet of Things
Solutions provided
Alliance Framework
→
→
IoT and Big Data
Analytics
IoT requires a generic solution to collect events and
data from different sources for further analysis.
Data can come from a specific framework, radio device,
sensor and others. How do we collect and unify data
properly ?
http://fluentbit.io
Fluent Bit
Open Source data collector
It let's you collect data from IoT/Embedded
devices and transport It to third party
services.
Fluent Bit
Targets
●
Services
●
Sensors / Signals / Radios
●
Operating System information
●
Automotive / Telematics
Fluent Bit
I/O
Fluent Bit
Direct Output
Fluent Bit
Architecture
Fluent Bit
Core Engine
●
Everything related to initialization.
●
Interface plugins.
●
Abstract network operations.
●
Make the magic happens.
Fluent Bit
Input Plugins
●
Collect data.
●
Behave as a network service, built-in
metric or generator.
●
It runs at intervals of time (triggered
by the Engine) or upon file descriptor
events.
Fluent Bit
Output Pllugins
●
Take buffered data and enqueue it
for delivery.
●
It knows how to send data to X
endpoint or service. Usually deal
with protocols.
Fluent Bit
Stack Providers
Fluent Bit have three dependencies
which are distributed in the source
code and are linked statically.
These components are helpers for
the Engine and Plugins Manager.
Fluent Bit
Monkey / HTTP Stack Provider
Monkey is a web server that provides
an embeddable HTTP stack and some
extra routines to handle configuration
files, memory handling, event loops,
string manipulation within others.
Fluent Bit
Library Mode
Join us!
Thank you!
●
http://monkey-project.com
●
http://duda.io
●
http://fluentbit.io
●
http://github.com/monkey
●
http://github.com/fluent
@edsiper

Weitere ähnliche Inhalte

Was ist angesagt?

Fixing Docker networking - Milos Gajdos at #DOXLON
Fixing Docker networking - Milos Gajdos at #DOXLONFixing Docker networking - Milos Gajdos at #DOXLON
Fixing Docker networking - Milos Gajdos at #DOXLONOutlyer
 
Nats.io meetup october 2015 - Community Update
Nats.io meetup october 2015 - Community UpdateNats.io meetup october 2015 - Community Update
Nats.io meetup october 2015 - Community UpdateBrian Flannery
 
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e... Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...VMware Tanzu
 
HTTP/2: Ask Me Anything
HTTP/2: Ask Me AnythingHTTP/2: Ask Me Anything
HTTP/2: Ask Me AnythingNGINX, Inc.
 
Everything as code - Johan Siebens STS presentation 14-01-2020
Everything as code - Johan Siebens STS presentation 14-01-2020Everything as code - Johan Siebens STS presentation 14-01-2020
Everything as code - Johan Siebens STS presentation 14-01-2020tothepointIT
 
How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
 How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecturevsoshnikov
 
Container Orchestration
Container OrchestrationContainer Orchestration
Container Orchestrationstrikr .
 
PHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the foolPHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the foolAlessandro Cinelli (cirpo)
 
Internals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementationInternals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementationRoger Leite
 
Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...vsoshnikov
 
Docker Webinar: From Windows 2003 to the Cloud
Docker Webinar: From Windows 2003 to the CloudDocker Webinar: From Windows 2003 to the Cloud
Docker Webinar: From Windows 2003 to the CloudElton Stoneman
 
JS digest. May 2017
JS digest. May 2017JS digest. May 2017
JS digest. May 2017ElifTech
 
Warsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataWarsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataPatryk Bandurski
 
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++Icinga
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5Steven Smith
 
Docker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationDocker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationRadek Baczynski
 

Was ist angesagt? (20)

Bio routing - DKNOG9
Bio routing  - DKNOG9Bio routing  - DKNOG9
Bio routing - DKNOG9
 
Dot Net Core
Dot Net CoreDot Net Core
Dot Net Core
 
Fixing Docker networking - Milos Gajdos at #DOXLON
Fixing Docker networking - Milos Gajdos at #DOXLONFixing Docker networking - Milos Gajdos at #DOXLON
Fixing Docker networking - Milos Gajdos at #DOXLON
 
Whats new in .net core 3
Whats new in .net core 3Whats new in .net core 3
Whats new in .net core 3
 
Nats.io meetup october 2015 - Community Update
Nats.io meetup october 2015 - Community UpdateNats.io meetup october 2015 - Community Update
Nats.io meetup october 2015 - Community Update
 
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e... Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
Cloud-Native .Net des applications containerisées .Net sur Linux, Windows e...
 
HTTP/2: Ask Me Anything
HTTP/2: Ask Me AnythingHTTP/2: Ask Me Anything
HTTP/2: Ask Me Anything
 
Everything as code - Johan Siebens STS presentation 14-01-2020
Everything as code - Johan Siebens STS presentation 14-01-2020Everything as code - Johan Siebens STS presentation 14-01-2020
Everything as code - Johan Siebens STS presentation 14-01-2020
 
Html 5 boot camp
Html 5 boot campHtml 5 boot camp
Html 5 boot camp
 
How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
 How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
How to Shrink from 5 Tiers to 2 in a Multitier Microservices Architecture
 
Container Orchestration
Container OrchestrationContainer Orchestration
Container Orchestration
 
PHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the foolPHP is the King, nodejs is the Prince and Lua is the fool
PHP is the King, nodejs is the Prince and Lua is the fool
 
Internals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementationInternals of OpenRuko PaaS, an open source Heroku clone implementation
Internals of OpenRuko PaaS, an open source Heroku clone implementation
 
Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...Master-Master Replication and Scaling of an Application Between Each of the I...
Master-Master Replication and Scaling of an Application Between Each of the I...
 
Docker Webinar: From Windows 2003 to the Cloud
Docker Webinar: From Windows 2003 to the CloudDocker Webinar: From Windows 2003 to the Cloud
Docker Webinar: From Windows 2003 to the Cloud
 
JS digest. May 2017
JS digest. May 2017JS digest. May 2017
JS digest. May 2017
 
Warsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft ODataWarsaw muleSoft meetup #11 MuleSoft OData
Warsaw muleSoft meetup #11 MuleSoft OData
 
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
Icinga Camp Berlin 2018 - Dev and Ops Stories - Integrations++
 
A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5A Whirldwind Tour of ASP.NET 5
A Whirldwind Tour of ASP.NET 5
 
Docker for mac & local developer environment optimization
Docker for mac & local developer environment optimizationDocker for mac & local developer environment optimization
Docker for mac & local developer environment optimization
 

Andere mochten auch

Andere mochten auch (8)

Disuluciones electricas
Disuluciones electricasDisuluciones electricas
Disuluciones electricas
 
Logging for Containers
Logging for ContainersLogging for Containers
Logging for Containers
 
Android HTTP Service
Android HTTP ServiceAndroid HTTP Service
Android HTTP Service
 
Unifying Events and Logs into the Cloud
Unifying Events and Logs into the CloudUnifying Events and Logs into the Cloud
Unifying Events and Logs into the Cloud
 
Containers and Logging
Containers and LoggingContainers and Logging
Containers and Logging
 
Fluent Bit
Fluent BitFluent Bit
Fluent Bit
 
Log forwarding at Scale
Log forwarding at ScaleLog forwarding at Scale
Log forwarding at Scale
 
PyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミングPyQtではじめるGUIプログラミング
PyQtではじめるGUIプログラミング
 

Ähnlich wie Lightweight open source data collection and transport for IoT and embedded

Unifying Events and Logs into the Cloud
Unifying Events and Logs into the CloudUnifying Events and Logs into the Cloud
Unifying Events and Logs into the CloudTreasure Data, Inc.
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server InternalsPraveen Gollakota
 
SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0Mike Belshe
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1tAmit Serper
 
Zing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat ArchitectZing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat ArchitectChau Thanh
 
FIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using KurentoFIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using KurentoFIWARE
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraLINAGORA
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openrestyTavish Naruka
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js PresentationExist
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2aspyker
 
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...Datacratic
 
FIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using KurentoFIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using KurentoFIWARE
 
The Fn Project by Jesse Butler
 The Fn Project by Jesse Butler The Fn Project by Jesse Butler
The Fn Project by Jesse ButlerOracle Developers
 
Serverless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupServerless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupWayne Scarano
 
Real Time Realitites
Real Time RealititesReal Time Realitites
Real Time Realititesmarkisuak
 
Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...
Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...
Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...Codemotion
 

Ähnlich wie Lightweight open source data collection and transport for IoT and embedded (20)

Fluent-bit
Fluent-bitFluent-bit
Fluent-bit
 
Unifying Events and Logs into the Cloud
Unifying Events and Logs into the CloudUnifying Events and Logs into the Cloud
Unifying Events and Logs into the Cloud
 
Tornado Web Server Internals
Tornado Web Server InternalsTornado Web Server Internals
Tornado Web Server Internals
 
SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0SPDY and What to Consider for HTTP/2.0
SPDY and What to Consider for HTTP/2.0
 
The internet of $h1t
The internet of $h1tThe internet of $h1t
The internet of $h1t
 
Zing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat ArchitectZing Me Real Time Web Chat Architect
Zing Me Real Time Web Chat Architect
 
FIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using KurentoFIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using Kurento
 
Angular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - LinagoraAngular (v2 and up) - Morning to understand - Linagora
Angular (v2 and up) - Morning to understand - Linagora
 
Socket programming, and openresty
Socket programming, and openrestySocket programming, and openresty
Socket programming, and openresty
 
Node.js Presentation
Node.js PresentationNode.js Presentation
Node.js Presentation
 
Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2Netflix Open Source Meetup Season 4 Episode 2
Netflix Open Source Meetup Season 4 Episode 2
 
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
RTBkit Meetup - Developer Spotlight, Behind the Scenes of RTBkit and Intro to...
 
FIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using KurentoFIWARE Global Summit - Real-time Media Stream Processing Using Kurento
FIWARE Global Summit - Real-time Media Stream Processing Using Kurento
 
Mina2
Mina2Mina2
Mina2
 
Nodejs
NodejsNodejs
Nodejs
 
The Fn Project by Jesse Butler
 The Fn Project by Jesse Butler The Fn Project by Jesse Butler
The Fn Project by Jesse Butler
 
Serverless Boston @ Oracle Meetup
Serverless Boston @ Oracle MeetupServerless Boston @ Oracle Meetup
Serverless Boston @ Oracle Meetup
 
Real Time Realitites
Real Time RealititesReal Time Realitites
Real Time Realitites
 
Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...
Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...
Open Source Serverless: a practical view. - Gabriele Provinciali Luca Postacc...
 
Python lecture 11
Python lecture 11Python lecture 11
Python lecture 11
 

Kürzlich hochgeladen

List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfisabel213075
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptJohnWilliam111370
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfShreyas Pandit
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Coursebim.edu.pl
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTSneha Padhiar
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectGayathriM270621
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating SystemRashmi Bhat
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfManish Kumar
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProRay Yuan Liu
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organizationchnrketan
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewsandhya757531
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical trainingGladiatorsKasper
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSneha Padhiar
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfDrew Moseley
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESkarthi keyan
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communicationpanditadesh123
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.elesangwon
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONjhunlian
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodManicka Mamallan Andavar
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmDeepika Walanjkar
 

Kürzlich hochgeladen (20)

List of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdfList of Accredited Concrete Batching Plant.pdf
List of Accredited Concrete Batching Plant.pdf
 
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.pptROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
ROBOETHICS-CCS345 ETHICS AND ARTIFICIAL INTELLIGENCE.ppt
 
Theory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdfTheory of Machine Notes / Lecture Material .pdf
Theory of Machine Notes / Lecture Material .pdf
 
Katarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School CourseKatarzyna Lipka-Sidor - BIM School Course
Katarzyna Lipka-Sidor - BIM School Course
 
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENTFUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
FUNCTIONAL AND NON FUNCTIONAL REQUIREMENT
 
STATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subjectSTATE TRANSITION DIAGRAM in psoc subject
STATE TRANSITION DIAGRAM in psoc subject
 
Input Output Management in Operating System
Input Output Management in Operating SystemInput Output Management in Operating System
Input Output Management in Operating System
 
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdfModule-1-(Building Acoustics) Noise Control (Unit-3). pdf
Module-1-(Building Acoustics) Noise Control (Unit-3). pdf
 
A brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision ProA brief look at visionOS - How to develop app on Apple's Vision Pro
A brief look at visionOS - How to develop app on Apple's Vision Pro
 
priority interrupt computer organization
priority interrupt computer organizationpriority interrupt computer organization
priority interrupt computer organization
 
Artificial Intelligence in Power System overview
Artificial Intelligence in Power System overviewArtificial Intelligence in Power System overview
Artificial Intelligence in Power System overview
 
70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training70 POWER PLANT IAE V2500 technical training
70 POWER PLANT IAE V2500 technical training
 
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATIONSOFTWARE ESTIMATION COCOMO AND FP CALCULATION
SOFTWARE ESTIMATION COCOMO AND FP CALCULATION
 
Immutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdfImmutable Image-Based Operating Systems - EW2024.pdf
Immutable Image-Based Operating Systems - EW2024.pdf
 
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTESCME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
CME 397 - SURFACE ENGINEERING - UNIT 1 FULL NOTES
 
multiple access in wireless communication
multiple access in wireless communicationmultiple access in wireless communication
multiple access in wireless communication
 
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
2022 AWS DNA Hackathon 장애 대응 솔루션 jarvis.
 
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTIONTHE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
THE SENDAI FRAMEWORK FOR DISASTER RISK REDUCTION
 
Levelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument methodLevelling - Rise and fall - Height of instrument method
Levelling - Rise and fall - Height of instrument method
 
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithmComputer Graphics Introduction, Open GL, Line and Circle drawing algorithm
Computer Graphics Introduction, Open GL, Line and Circle drawing algorithm
 

Lightweight open source data collection and transport for IoT and embedded

  • 2. Eduardo Silva ● Github & Twitter @edsiper ● Personal Blog http://edsiper.linuxchile.cl Treasure Data ● Open Source Engineer ● Fluentd / Fluent Bit http://github.com/fluent Projects ● Monkey HTTP Server http://monkey-project.com ● Duda I/O http://duda.io About Me
  • 3. HTTP Everywhere Use cases ● Home Automation ● Big Data ● Data Collection basically everywhere... ● Internet of Things ● Wearables ● Automotive
  • 5. Monkey HTTP Server Highlights ● Event driven ● Multi-thread ● Zero copy strategy ● Memory optimization ● Secure ● Optimized for Linux, but compatible with others. ● Embedded Linux / Yocto ● Open Source: Apache License v2.0
  • 6. Monkey HTTP Server Modular Design ● mk_core: agnostic runtime for handling of strings, memory, event loop, configuration reader, vectors and utilities within others. ● mk_server: TCP server, data streams, protocols, plugins manager, scheduler and general runtime setup. ● plugins: networking layer for I/O operations, stage handlers and content handlers.
  • 9. Monkey HTTP Server Master Process ● Prepare the environment. ● Read and process configuration. ● Load plugins and initialize them. ● Create a Scheduler instance. ● All things required before joining the event loop.
  • 10. Monkey HTTP Server Scheduler ● Balancing mode / OS check: ● Fair balancing ● Shared TCP ports (SO_REUSEPORT) ● Setup Listeners. ● Create the event loop for each worker. ● Handle incoming connections.
  • 11. Monkey HTTP Server Scheduler mode: Fair balancing ● One scheduler instance. ● It accepts all connections. ● Distribute to the less busy worker. ● Old fashion mechanism.
  • 12. Monkey HTTP Server Scheduler mode: Shared TCP ports ● Scheduler handler, one per worker. ● Connections are distributed by the Kernel. ● High performance, less contention. ● SO_REUSEPORT
  • 13. Monkey HTTP Server Scheduler: Listeners ● Bind a network address to listen for connections. ● TCP port ● Associate Network I/O layer handler plugin. ● Associate protocol handler for each connection.
  • 14. Monkey HTTP Server Workers ● Each worker have one event loop. ● Associate Listeners with connections. ● Handle protocol operations based on events notified. ● Timeout connections. ● Cleanup sessions.
  • 17. Monkey HTTP Server Plugins ● Monkey core provides only basic HTTP processing ● Plugins provides interfaces for: ● Network I/O operations ● Security ● Content Handling ● HTTP Stages / Hooks
  • 18. Monkey Plugins Network Layer: I/O ● Liana: Basic socket I/O handling, for short plain sockets. ● TLS: built on top of mbedTLS, provides SSL and TLS encryption capabilities when writing/reading data over sockets. “Monkey core and content handling plugins are not aware about how the network I/O is being handled, unless they ask for”
  • 19. Monkey Plugins Plugins: stages STAGE 10 Connection accepted. STAGE 20 Request have been received. STAGE 30 Content handler. STAGE 40 Response completed. STAGE 50 Connection closed. Each stage represents a phase of an incoming request cycle inside the server:
  • 20. Monkey Plugins Plugins: STAGE 10 Every time a connection is accepted by the scheduler, the plugins associated with this stage are triggered. The security plugin mandril, hooks to this stage and provides restrictions by IP.
  • 21. Monkey Plugins Plugins: STAGE 20 This stage triggers the plugins callbacks every time a request have arrived successfully to the server.
  • 22. Monkey Plugins Plugins: STAGE 30 Well known as the content handler, owns the request and process a response. Some plugins that works at this level are: ● FastCGI ● CGI ● Directory Listing ● Duda I/O
  • 23. Monkey Plugins Plugins: STAGE 40 Once a request have finished like completed successfully or due to an exception, this stage is triggered. The logger plugin makes use of this stage to make sure to register all kind of events.
  • 24. Monkey Plugins Plugins: STAGE 50 This stage triggers the associated callbacks every time a TCP connection is closed by a protocol, scheduler timeout or due to any network anomaly found.
  • 25. Monkey HTTP Server Memory Handling ● Just one memory allocation per TCP connection. ● Jemalloc memory allocator built-in by default, if desired it can be disabled at build time.
  • 26. Monkey HTTP Server System calls / Tweaks ● sendfile(2) static content delivery ● writev(2) write multiple buffers as an array (headers) ● splice(2) move data between file descriptors (logger) ● epoll(7) I/O event notification on Linux ● kqueue(2) I/O event notification on OSX & BSD ● accept4(2) accept connection and set option (non block) ● TCP_CORK send only full packets (on-demand) ● SO_REUSEPORT shared TCP ports (if available) ● SOCK_NONBLOCK non-blocking sockets
  • 27. Monkey HTTP Server Clock thread: cached date The server spawns a thread named clock. It basically update a local memory buffer with a formatted version of the current time. This info is mandatory in the response header. note: if you get 1000 request per second, you don't want to do a string formatting 1000 times for the same time.
  • 28. Monkey HTTP Server Indented Configuration Force people to use an indented format, avoid a spaghetti configuration. note: it works!, read Python code ;)
  • 29. Monkey HTTP Server Linux Kernel detection If running on Linux, check the Kernel version and enable some features if they are available, e.g: ● TCP_FASTOPEN ● SO_REUSEPORT ● TCP_AUTOCORKING (currently disabled)
  • 30. Monkey HTTP Server Embedded Linux ● Monkey is a Yocto compliant project and available through meta-openembedded. ● We distribute packages for Raspbian
  • 31. Monkey HTTP Server General features ● HTTP/1.1 ● Virtual Hosts ● IPv4 / IPv6 ● TLS/SSL ● CGI ● FastCGI ● Directory Listing ● Log Writer ● Basic Authentication
  • 33. Monkey and HTTP/2.0 Status ● Internals need some rewrite to start implementing the new version of the protocol: done. ● Listener must support multiple protocols: done. ● HTTP/2.0 handshake and further spec: work in process. The goal is to have a functional HTTP/2.0 version before the end of this year. The hard part were to extend the internals to start supporting all requirements.
  • 34. Monkey Roadmap ● HTTP/2.0 ● Proxy reverse ● Restore library mode ● Co-routines ● Logging Layer instead of plugin hooks. ● URL rewrite support.
  • 36. Web Services What do we usually expect ● Lightweight ? ● High Performance ? ● Extensible ? ● Scalabale ? ● Secure ? ●
  • 37. Web Services A short story, facts: ● Company X was developing an Apnea monitoring product for in-house usage (2011). ● Target device was a low cost ARM end device. ● They develop their web service in Java. ● When they ported the web service to the ARM device, each HTTP request took a few seconds to reply =/ .
  • 38. Web Services Workarounds ● Use a more expensive ARM device that Java supported better ? ● Pay $Oracle to improve Java for that specific ARM architecture ? ● Build the web service in a better language from scratch ?
  • 39. Web Services Almost write from scratch ● Monkey was already optimized for ARM, it have an extensible architecture. ● Write a Monkey extension that provides a flexible and easy C API to implement web services. ● So a new project was born...
  • 41. Duda I/O About ● Duda is a scalable web services stack (made in C). ● x86, x86_64 & ARM. ● Open Source / Apache License v2.0 . ● Target: high end production servers and Embedded Linux.
  • 42. Duda I/O Features ● Event driven ● Friendly C API / Objects ● Co-routines ● HTTP / HTTPS ● WebSockets ● JSON / MySQL / Redis / SQLite ● Packages support ● In-memory Key value store ● much more!...
  • 45. Duda I/O Production ready ● Big Data ● Real Time Bidding ● Home Automation ● Mobile Backends ● Etc...
  • 47. Internet of Things Facts ● IoT will grow to many billions of devices over the next decade. ● Now it's about device to device connectivity. ● Different frameworks and protocols are emerging. ● It needs Logging.
  • 48. Internet of Things Alliances Vendors formed alliances to join forces and develop generic software layers for their products:
  • 49. Internet of Things Solutions provided Alliance Framework → →
  • 50. IoT and Big Data Analytics IoT requires a generic solution to collect events and data from different sources for further analysis. Data can come from a specific framework, radio device, sensor and others. How do we collect and unify data properly ?
  • 52. Fluent Bit Open Source data collector It let's you collect data from IoT/Embedded devices and transport It to third party services.
  • 53. Fluent Bit Targets ● Services ● Sensors / Signals / Radios ● Operating System information ● Automotive / Telematics
  • 57. Fluent Bit Core Engine ● Everything related to initialization. ● Interface plugins. ● Abstract network operations. ● Make the magic happens.
  • 58. Fluent Bit Input Plugins ● Collect data. ● Behave as a network service, built-in metric or generator. ● It runs at intervals of time (triggered by the Engine) or upon file descriptor events.
  • 59. Fluent Bit Output Pllugins ● Take buffered data and enqueue it for delivery. ● It knows how to send data to X endpoint or service. Usually deal with protocols.
  • 60. Fluent Bit Stack Providers Fluent Bit have three dependencies which are distributed in the source code and are linked statically. These components are helpers for the Engine and Plugins Manager.
  • 61. Fluent Bit Monkey / HTTP Stack Provider Monkey is a web server that provides an embeddable HTTP stack and some extra routines to handle configuration files, memory handling, event loops, string manipulation within others.