SlideShare une entreprise Scribd logo
1  sur  16
How netfilter saved my
                         bacon


                                   Fred Moyer
                                  @phredmoyer
                             Silver Lining Networks


Thursday, September 27, 12
Free WiFi!
                  Ad bar inserted at the top of page pays the WiFi bill
                           (Silver Lining Ad Bar shown here)


Thursday, September 27, 12
Others have built it, you may have used
                   theirs (notice this page didn’t load fully)

Thursday, September 27, 12
How does theirs work?
                    • Tinyproxy runs on the network gateway
                    • Inserts Javascript into the HTTP response
                             which splits the page into two frames, one
                             for the ad bar, one for the web page content
                    • Proxying HTTP responses through
                             userspace on network devices is *slow*
                    • Users get angry; this solution sucks
Thursday, September 27, 12
Ignorance is bliss; how I
                               built it from scratch
                    • iptables rules on the gateway device NAT
                             forwarded HTTP requests to co-located
                             mod_perl web proxy
                    • Better performance than tinyproxy
                    • Running all web traffic through colocation
                             doesn’t scale though (and is really
                             expensive)


Thursday, September 27, 12
Making it scale
                    •        Avoid sending static content requests (images,
                             videos, etc) through the colocated proxy

                    •        HTTP proxy rewrites static content links:

                             •   http://foo.com/image.jpg =>

                                 •   http://foo.com:8135/image.jpg

                    •        Redirect port 8135 to port 80 via router iptables
                             rule:

                             •   iptables -t NAT -A PREROUTING -i $LAN -p tcp
                                 --dport 8135 -j DNAT --to :80


Thursday, September 27, 12
Scalability achieved
                    • 95% of traffic offloaded from the co-
                             located proxy and fetched directly from the
                             destination
                    • Hillbilly architecture driven by desperation
                             and experimentation rather than elegant
                             planning
                    • Performance was much better than the
                             tinyproxy approach used by competitors


Thursday, September 27, 12
Yo dawg, I heard you
                                  like 400s
                    •        Whoops, it doesn’t completely work

                    •        Apache handles http://foo.com:8135 requests
                             to port 80 just fine

                    •        lighttpd throws a 400 Bad Request!

                    •        ~20% of static content requests returning 400s
                             makes users (and network operators) angry



Thursday, September 27, 12
Linux based routers use the sk_buff socket buffer
                    struct in kernel space. Maybe a netfilter module can
                          remove the :8135 from the hostname...

Thursday, September 27, 12
3 months of Netfilter coding




Thursday, September 27, 12
Architectural Overview
                                           gateway iptables
                                           redirect to proxy
 GET http://foo.com/                                                       HTTP proxy

                             iptables -t NAT -A PREROUTING -i $LAN -p tcp --dport 80
                               --dst ! 192.168.0.0/16 -j DNAT --to 69.36.240.29:80




Thursday, September 27, 12
Architectural Overview
                                      gateway iptables
                                      redirect to proxy
 GET http://foo.com/                                                HTTP proxy
                                     html response with ad,
                                  subrequest hrefs on port 8135



                                                                    index.html
                                                                  proxied request




                                                                     foo.com



Thursday, September 27, 12
Architectural Overview
                                      gateway iptables
                                      redirect to proxy
 GET http://foo.com/                                                HTTP proxy
                                     html response with ad,
                                  subrequest hrefs on port 8135



                                                                    index.html
      browser parses page,                                        proxied request
     makes image subrequest




 GET http://foo.com:8135/bar.jpg                                     foo.com



Thursday, September 27, 12
Architectural Overview
                                      gateway iptables
                                      redirect to proxy
 GET http://foo.com/                                                  HTTP proxy
                                     html response with ad,
                                  subrequest hrefs on port 8135



                                                                    index.html
      browser parses page,                                        proxied request
     makes image subrequest



                                           netfilter module removes
                                                :8135 hostport
 GET http://foo.com:8135/bar.jpg                                      foo.com
                                         subrequest bypasses proxy,
                                           fetches image directly




Thursday, September 27, 12
It works (finally)
                    •        ‘Host: foo.com:8135’ => ‘Host: foo.com’ in
                             kernel space. No user space copying.
                    •        < 500 ms additional latency for main page
                             requests through the co-located HTTP proxy
                    •        Blows tinyproxy out of the water
                    •        Product didn’t survive business needs though,
                             the ad revenue wasn’t there :(


Thursday, September 27, 12
Thank you Surge 2012

                    • Stuck in an architectural dead end?
                             Maybe this approach can help you.
                    • github.com/redhotpenguin/SL-Kernel
                    • www.skbuff.net/skbuff.html
                    • banu.com/tinyproxy

Thursday, September 27, 12

Contenu connexe

En vedette

Germany and outbreak of ww2 1
Germany and outbreak of ww2 1Germany and outbreak of ww2 1
Germany and outbreak of ww2 1Ashraf Atique
 
case study starwood hotels and resorts worldwide discuss
case study starwood hotels and resorts worldwide discusscase study starwood hotels and resorts worldwide discuss
case study starwood hotels and resorts worldwide discussMediabistro
 
Geocapabilties: teacher leadership
Geocapabilties: teacher leadershipGeocapabilties: teacher leadership
Geocapabilties: teacher leadershipKarl Donert
 
London y sus secretos
London y sus secretosLondon y sus secretos
London y sus secretosbielcallarisa
 
Webquest género literario
Webquest género literarioWebquest género literario
Webquest género literarioKARLA PAREDES
 
The Stock Market Crash Of 1929
The Stock Market Crash Of 1929The Stock Market Crash Of 1929
The Stock Market Crash Of 1929Bryan Toth
 
Linux 的檔案系統格式介紹
Linux 的檔案系統格式介紹Linux 的檔案系統格式介紹
Linux 的檔案系統格式介紹Ma Yu-Hui
 

En vedette (10)

Osas
OsasOsas
Osas
 
Germany and outbreak of ww2 1
Germany and outbreak of ww2 1Germany and outbreak of ww2 1
Germany and outbreak of ww2 1
 
case study starwood hotels and resorts worldwide discuss
case study starwood hotels and resorts worldwide discusscase study starwood hotels and resorts worldwide discuss
case study starwood hotels and resorts worldwide discuss
 
Geocapabilties: teacher leadership
Geocapabilties: teacher leadershipGeocapabilties: teacher leadership
Geocapabilties: teacher leadership
 
London y sus secretos
London y sus secretosLondon y sus secretos
London y sus secretos
 
Mono
MonoMono
Mono
 
Webquest género literario
Webquest género literarioWebquest género literario
Webquest género literario
 
The Stock Market Crash Of 1929
The Stock Market Crash Of 1929The Stock Market Crash Of 1929
The Stock Market Crash Of 1929
 
Distribution Telecom
Distribution   TelecomDistribution   Telecom
Distribution Telecom
 
Linux 的檔案系統格式介紹
Linux 的檔案系統格式介紹Linux 的檔案系統格式介紹
Linux 的檔案系統格式介紹
 

Similaire à Surge 2012 fred_moyer_lightning

Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...Baruch Sadogursky
 
What is Digital Rebar Provision (and how RackN extends)?
What is Digital Rebar Provision (and how RackN extends)?What is Digital Rebar Provision (and how RackN extends)?
What is Digital Rebar Provision (and how RackN extends)?rhirschfeld
 
Ruby - Behind the Scenes
Ruby -  Behind the ScenesRuby -  Behind the Scenes
Ruby - Behind the ScenesKenneth Kalmer
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)Peter Lubbers
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)Stoyan Zhekov
 
Railswaycon 2009 - Summary
Railswaycon 2009 - SummaryRailswaycon 2009 - Summary
Railswaycon 2009 - Summarydaniel.mattes
 
Ruby Conf Preso
Ruby Conf PresoRuby Conf Preso
Ruby Conf PresoDan Yoder
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?Altoros
 
ActionEmbedding
ActionEmbeddingActionEmbedding
ActionEmbeddingphilcowans
 
Apache httpd 2.4 overview
Apache httpd 2.4 overviewApache httpd 2.4 overview
Apache httpd 2.4 overviewJim Jagielski
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkPeter Edwards
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Arun Gupta
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityPeter Lubbers
 
Puppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetPuppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetNan Liu
 
BeAPI API Framework
BeAPI API FrameworkBeAPI API Framework
BeAPI API FrameworkOwen Rubel
 
2012-04-21-ignite-offline-mobile-app-has-great-potential
2012-04-21-ignite-offline-mobile-app-has-great-potential2012-04-21-ignite-offline-mobile-app-has-great-potential
2012-04-21-ignite-offline-mobile-app-has-great-potentialKenichi Murahashi
 

Similaire à Surge 2012 fred_moyer_lightning (20)

Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
Building a private CI/CD pipeline with Java and Docker in the Cloud as presen...
 
What is Digital Rebar Provision (and how RackN extends)?
What is Digital Rebar Provision (and how RackN extends)?What is Digital Rebar Provision (and how RackN extends)?
What is Digital Rebar Provision (and how RackN extends)?
 
Ruby - Behind the Scenes
Ruby -  Behind the ScenesRuby -  Behind the Scenes
Ruby - Behind the Scenes
 
Reverse proxy magic
Reverse proxy magicReverse proxy magic
Reverse proxy magic
 
Where is my scalable API?
Where is my scalable API?Where is my scalable API?
Where is my scalable API?
 
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
HTML5 Real Time and WebSocket Code Lab (SFHTML5, GTUGSF)
 
Ruby off Rails (english)
Ruby off Rails (english)Ruby off Rails (english)
Ruby off Rails (english)
 
Vertx
VertxVertx
Vertx
 
Railswaycon 2009 - Summary
Railswaycon 2009 - SummaryRailswaycon 2009 - Summary
Railswaycon 2009 - Summary
 
Ruby Conf Preso
Ruby Conf PresoRuby Conf Preso
Ruby Conf Preso
 
Where is my scalable api?
Where is my scalable api?Where is my scalable api?
Where is my scalable api?
 
ActionEmbedding
ActionEmbeddingActionEmbedding
ActionEmbedding
 
Apache httpd 2.4 overview
Apache httpd 2.4 overviewApache httpd 2.4 overview
Apache httpd 2.4 overview
 
Desperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl frameworkDesperately seeking a lightweight Perl framework
Desperately seeking a lightweight Perl framework
 
Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014Nuts and Bolts of WebSocket Devoxx 2014
Nuts and Bolts of WebSocket Devoxx 2014
 
HTML5 Real-Time and Connectivity
HTML5 Real-Time and ConnectivityHTML5 Real-Time and Connectivity
HTML5 Real-Time and Connectivity
 
Puppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with PuppetPuppet Conf 2012 - Managing Network Devices with Puppet
Puppet Conf 2012 - Managing Network Devices with Puppet
 
BeAPI API Framework
BeAPI API FrameworkBeAPI API Framework
BeAPI API Framework
 
2012-04-21-ignite-offline-mobile-app-has-great-potential
2012-04-21-ignite-offline-mobile-app-has-great-potential2012-04-21-ignite-offline-mobile-app-has-great-potential
2012-04-21-ignite-offline-mobile-app-has-great-potential
 
Html5 tx - preso
Html5 tx - presoHtml5 tx - preso
Html5 tx - preso
 

Plus de Fred Moyer

Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+Fred Moyer
 
Practical service level objectives with error budgeting
Practical service level objectives with error budgetingPractical service level objectives with error budgeting
Practical service level objectives with error budgetingFred Moyer
 
SREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done RightSREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done RightFred Moyer
 
Scale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done RightScale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done RightFred Moyer
 
Latency SLOs Done Right
Latency SLOs Done RightLatency SLOs Done Right
Latency SLOs Done RightFred Moyer
 
Latency SLOs done right
Latency SLOs done rightLatency SLOs done right
Latency SLOs done rightFred Moyer
 
Comprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and IstioComprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and IstioFred Moyer
 
Comprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioComprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioFred Moyer
 
Effective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsEffective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsFred Moyer
 
Statistics for dummies
Statistics for dummiesStatistics for dummies
Statistics for dummiesFred Moyer
 
GrafanaCon EU 2018
GrafanaCon EU 2018GrafanaCon EU 2018
GrafanaCon EU 2018Fred Moyer
 
Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017Fred Moyer
 
Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016Fred Moyer
 
Better service monitoring through histograms
Better service monitoring through histogramsBetter service monitoring through histograms
Better service monitoring through histogramsFred Moyer
 
The Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseThe Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseFred Moyer
 
Learning go for perl programmers
Learning go for perl programmersLearning go for perl programmers
Learning go for perl programmersFred Moyer
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache DispatchFred Moyer
 
Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008Fred Moyer
 
Data::FormValidator Simplified
Data::FormValidator SimplifiedData::FormValidator Simplified
Data::FormValidator SimplifiedFred Moyer
 

Plus de Fred Moyer (20)

Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+Reliable observability at scale: Error Budgets for 1,000+
Reliable observability at scale: Error Budgets for 1,000+
 
Practical service level objectives with error budgeting
Practical service level objectives with error budgetingPractical service level objectives with error budgeting
Practical service level objectives with error budgeting
 
SREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done RightSREcon americas 2019 - Latency SLOs Done Right
SREcon americas 2019 - Latency SLOs Done Right
 
Scale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done RightScale17x - Latency SLOs Done Right
Scale17x - Latency SLOs Done Right
 
Latency SLOs Done Right
Latency SLOs Done RightLatency SLOs Done Right
Latency SLOs Done Right
 
Latency SLOs done right
Latency SLOs done rightLatency SLOs done right
Latency SLOs done right
 
Comprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and IstioComprehensive Container Based Service Monitoring with Kubernetes and Istio
Comprehensive Container Based Service Monitoring with Kubernetes and Istio
 
Comprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istioComprehensive container based service monitoring with kubernetes and istio
Comprehensive container based service monitoring with kubernetes and istio
 
Effective management of high volume numeric data with histograms
Effective management of high volume numeric data with histogramsEffective management of high volume numeric data with histograms
Effective management of high volume numeric data with histograms
 
Statistics for dummies
Statistics for dummiesStatistics for dummies
Statistics for dummies
 
GrafanaCon EU 2018
GrafanaCon EU 2018GrafanaCon EU 2018
GrafanaCon EU 2018
 
Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017Fredmoyer postgresopen 2017
Fredmoyer postgresopen 2017
 
Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016Better service monitoring through histograms sv perl 09012016
Better service monitoring through histograms sv perl 09012016
 
Better service monitoring through histograms
Better service monitoring through histogramsBetter service monitoring through histograms
Better service monitoring through histograms
 
The Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL DatabaseThe Breakup - Logically Sharding a Growing PostgreSQL Database
The Breakup - Logically Sharding a Growing PostgreSQL Database
 
Learning go for perl programmers
Learning go for perl programmersLearning go for perl programmers
Learning go for perl programmers
 
Qpsmtpd
QpsmtpdQpsmtpd
Qpsmtpd
 
Apache Dispatch
Apache DispatchApache Dispatch
Apache Dispatch
 
Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008Ball Of Mud Yapc 2008
Ball Of Mud Yapc 2008
 
Data::FormValidator Simplified
Data::FormValidator SimplifiedData::FormValidator Simplified
Data::FormValidator Simplified
 

Dernier

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontologyjohnbeverley2021
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Victor Rentea
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Dernier (20)

Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Surge 2012 fred_moyer_lightning

  • 1. How netfilter saved my bacon Fred Moyer @phredmoyer Silver Lining Networks Thursday, September 27, 12
  • 2. Free WiFi! Ad bar inserted at the top of page pays the WiFi bill (Silver Lining Ad Bar shown here) Thursday, September 27, 12
  • 3. Others have built it, you may have used theirs (notice this page didn’t load fully) Thursday, September 27, 12
  • 4. How does theirs work? • Tinyproxy runs on the network gateway • Inserts Javascript into the HTTP response which splits the page into two frames, one for the ad bar, one for the web page content • Proxying HTTP responses through userspace on network devices is *slow* • Users get angry; this solution sucks Thursday, September 27, 12
  • 5. Ignorance is bliss; how I built it from scratch • iptables rules on the gateway device NAT forwarded HTTP requests to co-located mod_perl web proxy • Better performance than tinyproxy • Running all web traffic through colocation doesn’t scale though (and is really expensive) Thursday, September 27, 12
  • 6. Making it scale • Avoid sending static content requests (images, videos, etc) through the colocated proxy • HTTP proxy rewrites static content links: • http://foo.com/image.jpg => • http://foo.com:8135/image.jpg • Redirect port 8135 to port 80 via router iptables rule: • iptables -t NAT -A PREROUTING -i $LAN -p tcp --dport 8135 -j DNAT --to :80 Thursday, September 27, 12
  • 7. Scalability achieved • 95% of traffic offloaded from the co- located proxy and fetched directly from the destination • Hillbilly architecture driven by desperation and experimentation rather than elegant planning • Performance was much better than the tinyproxy approach used by competitors Thursday, September 27, 12
  • 8. Yo dawg, I heard you like 400s • Whoops, it doesn’t completely work • Apache handles http://foo.com:8135 requests to port 80 just fine • lighttpd throws a 400 Bad Request! • ~20% of static content requests returning 400s makes users (and network operators) angry Thursday, September 27, 12
  • 9. Linux based routers use the sk_buff socket buffer struct in kernel space. Maybe a netfilter module can remove the :8135 from the hostname... Thursday, September 27, 12
  • 10. 3 months of Netfilter coding Thursday, September 27, 12
  • 11. Architectural Overview gateway iptables redirect to proxy GET http://foo.com/ HTTP proxy iptables -t NAT -A PREROUTING -i $LAN -p tcp --dport 80 --dst ! 192.168.0.0/16 -j DNAT --to 69.36.240.29:80 Thursday, September 27, 12
  • 12. Architectural Overview gateway iptables redirect to proxy GET http://foo.com/ HTTP proxy html response with ad, subrequest hrefs on port 8135 index.html proxied request foo.com Thursday, September 27, 12
  • 13. Architectural Overview gateway iptables redirect to proxy GET http://foo.com/ HTTP proxy html response with ad, subrequest hrefs on port 8135 index.html browser parses page, proxied request makes image subrequest GET http://foo.com:8135/bar.jpg foo.com Thursday, September 27, 12
  • 14. Architectural Overview gateway iptables redirect to proxy GET http://foo.com/ HTTP proxy html response with ad, subrequest hrefs on port 8135 index.html browser parses page, proxied request makes image subrequest netfilter module removes :8135 hostport GET http://foo.com:8135/bar.jpg foo.com subrequest bypasses proxy, fetches image directly Thursday, September 27, 12
  • 15. It works (finally) • ‘Host: foo.com:8135’ => ‘Host: foo.com’ in kernel space. No user space copying. • < 500 ms additional latency for main page requests through the co-located HTTP proxy • Blows tinyproxy out of the water • Product didn’t survive business needs though, the ad revenue wasn’t there :( Thursday, September 27, 12
  • 16. Thank you Surge 2012 • Stuck in an architectural dead end? Maybe this approach can help you. • github.com/redhotpenguin/SL-Kernel • www.skbuff.net/skbuff.html • banu.com/tinyproxy Thursday, September 27, 12