SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Comet implementations for Perl




                                    Marian HackMan Marinov
                               Co-founder and CEO of 1H Ltd.
                                               mm@1h.com
Bulgarian Perl Workshop 2013
Replacing browser PULL
                               with server PUSH

       What is Comet?



                               AJAX Push
                               Reverse AJAX
                               Two-way-web
                               HTTP Streaming
                               HTTP Server Push
Bulgarian Perl Workshop 2013
Hidden iframe
                               XMLHttpRequest
                               long polling with
                                  - AJAX
                                  - XMLHttpRequest
                                  - Script tag




      Implementations



Bulgarian Perl Workshop 2013
Bulgarian Perl Workshop 2013
Iframe sent as                          Hidden iframe
  chunked blcok

  Infinitely long




                               Works on every browser

                               Lacks reliable error handling
                               Connection state unavailable

Bulgarian Perl Workshop 2013
hackman@gamelon:~$ curl http://localhost:4670/push/12345/iframe/channel1
<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"
<meta http-equiv="Cache-Control" content="no-store">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="Thu, 1 Jan 1970 00:00:00 GMT">
</head>
<body>
<script>document.getElementById('counter').innerHTML = '1';</script>
<script>document.getElementById('counter').innerHTML = '2';</script>
<script>document.getElementById('counter').innerHTML = '3';</script>
<script>document.getElementById('counter').innerHTML = '4';</script>
<script>document.getElementById('counter').innerHTML = '5';</script>
<script>document.getElementById('counter').innerHTML = '6';</script>

<html>
<head>
<title>Comet test Page</title>
</head>
<body>
<h2 align="center">My counter: </h2> <span id='counter'></span>
<iframe href='http://localhost:8000' height=0 width=0></iframe>
</body>
</html>

Bulgarian Perl Workshop 2013
XMLHttpRequest
Content-type:
 multipart/x-mixed-replace;
 boundary=NEXTPARTrnrn




                               The Ajax way of using Comet
                               Reliable connection handling
                               Connection state information



Bulgarian Perl Workshop 2013
hackman@gamelon:~$ curl http://localhost:8000/

--NEXTPART
Content-type: text/plain

<script>document.getElementById('counter').innerHTML = '0';</script>
--NEXTPART
Content-type: text/plain

<script>document.getElementById('counter').innerHTML = '1';</script>
--NEXTPART
Content-type: text/plain

<script>document.getElementById('counter').innerHTML = '2';</script>
--NEXTPART




Bulgarian Perl Workshop 2013
Long Polling




XMLHttpRequest
- creates a request
- when all data is received
- creates subsequent request


Bulgarian Perl Workshop 2013
Long Polling




<script> tag
- creates a script tag
- when all data is received
- creates new script tag


Bulgarian Perl Workshop 2013
Meteor
                               Stardust

                               Frameworks:
                                - Mojolicious
                                - PSGI
                                - Continuity




What Comet implementations
we have in Perl


Bulgarian Perl Workshop 2013
http://meteorserver.org/



 Meteor



                               Stand alone web server
                               Supports:
                                - iframe
                                - xhrinteractive
                               - simplepoll & smartpoll
                               - longpoll
                               - flash & flashloadvars

Bulgarian Perl Workshop 2013
Event controller commands




                               ADDMESSAGE chan msg
                               COUNTSUBSCRIBERS chan
                               LISTCHANNELS
                               SHOWSTATS
                               QUIT
Bulgarian Perl Workshop 2013
hackman@gamelon:~/Comet$ nc localhost 4671
  SHOWSTATS
  OK
  uptime: 279
  channel_count: 0
  subscriber_connections_accepted: 3
  controller_connections_accepted: 1
  total_inbound_bytes: 524
  total_outbound_bytes: 646
  documents_not_found: 3
  current_controllers: 1
  total_requests: 4
  current_subscribers: 0
  --EOT--
  ADDMESSAGE channel1 testing
  OK     0
  LISTCHANNELS
  OK
  channel1(1/0)
  --EOT--
  ADDMESSAGE channel1 dddddd
  OK     1
Bulgarian Perl Workshop 2013
$ curl http://localhost:4670/push/12345/iframe/channel1
  <html><head>
  <script type="text/javascript">
  window.onError = null;
  var domainparts = document.domain.split(".");
  document.domain = domainparts[domainparts.length-2]+".
   "+domainparts[domainparts.length-1];
  parent.Meteor.register(this);
  </script>
  </head>
  <body onload="try { parent.Meteor.reset(this) } catch (e) {}">
  <script>ch("channel1", 1);</script>

  <script>p(-1,"");</script>
  <script>p(-1,"");</script>
  <script>p(2,"channel1","fufufu");</script>
  <script>p(-1,"");</script>
  ^C
  hackman@gamelon:~$

Bulgarian Perl Workshop 2013
$ curl http://localhost:4670/push/12345/xhrinteractive/channel1
.............................................................................................................
.............................................................................................................
.............................................................................................................
.............................................................................................................
.............................................................................................................
.........................................
<script>ch("channel1", 2);</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(3,"channel1","s1dasda");</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
^C

hackman@gamelon:~$

 Bulgarian Perl Workshop 2013
$ curl http://localhost:4670/push/12345/simplepoll/channel1
<script>ch("channel1", 3);</script>
hackman@gamelon:~$

$ curl http://localhost:4670/push/12345/smartpoll/channel1
<script>ch("channel1", 3);</script>
hackman@gamelon:~$

$ curl http://localhost:4670/push/12345/longpoll/channel1
<script>ch("channel1", 3);</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(-1,"");</script>
<script>p(4,"channel1","gtwedsada");</script>
hackman@gamelon:~$



Bulgarian Perl Workshop 2013
Stand alone web server
Almost no documentation                  Stardust
No updates since 2011
Supports:
stream and longpoll




remove With::Log from stardust.pl   cpan Stardust

Bulgarian Perl Workshop 2013
$ curl -d 'm={ "type": "Test", "data": [1,2,3] }' http://localhost:5742/channel/foo/stream/foo/
/channel/foo/stream/foo/ not found.[root@gamelon script]#
hackman@gamelon:~$
$ curl -d 'm={ "type": "Test", "data": [1,2,3] }' http://localhost:5742/channel/foo
$ curl http://localhost:5742/channel/foo
[{"messages":[{"_ts":1360399562.89221,"data":[1,2,3],"type":"Test","_ch":"foo"}],
  "name":"foo","subscribers":[],"size":8,"i":1}]
hackman@gamelon:~$

$ curl -d 'm={ "type": "Test", "data": [2,3] }' http://localhost:5742/channel/foo
$ curl http://localhost:5742/channel/foo
[{"messages":[{"_ts":1360399562.89221,"data":[1,2,3],"type":"Test","_ch":"foo"},
  {"_ts":1360399605.81986,"data":[2,3],"type":"Test","_ch":"foo"}],
  "name":"foo","subscribers":[],"size":8,"i":2}]


Bulgarian Perl Workshop 2013
Other Perl comet implementations:
 - POE-Component-Server-Bayeux
 - Tatsumaki




 Additional readings:
   http://toroid.org/ams/etc/mojolicious-http-streaming
   http://infrequently.org/2006/03/comet-low-latency-data-for-the-browser/
  http://showmetheco.de/articles/2011/2/diving-into-html5-with-websockets-and-perl.html


Bulgarian Perl Workshop 2013
More on the subject here:
          http://www.slideshare.net/simon/time-for-comet


         ?                     ?
                                       ?                  ?
               ?
                               ?       ?
  ?       My slides can be found here:                ?
           http://www.slideshare.net/azilian/perl-comet
Bulgarian Perl Workshop 2013

Weitere ähnliche Inhalte

Was ist angesagt?

Genkidama:実装と課題
Genkidama:実装と課題Genkidama:実装と課題
Genkidama:実装と課題Takuya ASADA
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comIlya Grigorik
 
Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.Evgeniy Kuzmin
 
0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web servicesIlya Grigorik
 
Inter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message QueuesInter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message Queueswamcvey
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr VronskiyFwdays
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Applicationguest1f2740
 
Crash course to the Apache Camel
Crash course to the Apache CamelCrash course to the Apache Camel
Crash course to the Apache CamelHenryk Konsek
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ilya Grigorik
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsSerge Smetana
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringIlya Grigorik
 
Rails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & ToolsRails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & Toolsguest05c09d
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzJBug Italy
 
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...Chris Fregly
 
Service workers - Velocity 2016 Training
Service workers - Velocity 2016 TrainingService workers - Velocity 2016 Training
Service workers - Velocity 2016 TrainingPatrick Meenan
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slowaragozin
 
Mobile web performance - MoDev East
Mobile web performance - MoDev EastMobile web performance - MoDev East
Mobile web performance - MoDev EastPatrick Meenan
 
HAProxy tech talk
HAProxy tech talkHAProxy tech talk
HAProxy tech talkicebourg
 

Was ist angesagt? (20)

Genkidama:実装と課題
Genkidama:実装と課題Genkidama:実装と課題
Genkidama:実装と課題
 
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.comRuby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
Ruby Proxies for Scale, Performance, and Monitoring - GoGaRuCo - igvita.com
 
Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.Smart Gamma - Real-Time Web applications with PHP and Websocket.
Smart Gamma - Real-Time Web applications with PHP and Websocket.
 
0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services0-60 with Goliath: High performance web services
0-60 with Goliath: High performance web services
 
Inter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message QueuesInter-Process/Task Communication With Message Queues
Inter-Process/Task Communication With Message Queues
 
"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy"Swoole: double troubles in c", Alexandr Vronskiy
"Swoole: double troubles in c", Alexandr Vronskiy
 
Find bottleneck and tuning in Java Application
Find bottleneck and tuning in Java ApplicationFind bottleneck and tuning in Java Application
Find bottleneck and tuning in Java Application
 
Crash course to the Apache Camel
Crash course to the Apache CamelCrash course to the Apache Camel
Crash course to the Apache Camel
 
Railsconf
RailsconfRailsconf
Railsconf
 
Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09Ruby C10K: High Performance Networking - RubyKaigi '09
Ruby C10K: High Performance Networking - RubyKaigi '09
 
Performance Optimization of Rails Applications
Performance Optimization of Rails ApplicationsPerformance Optimization of Rails Applications
Performance Optimization of Rails Applications
 
Ruby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and MonitoringRuby Proxies for Scale, Performance, and Monitoring
Ruby Proxies for Scale, Performance, and Monitoring
 
Rails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & ToolsRails Application Optimization Techniques & Tools
Rails Application Optimization Techniques & Tools
 
Faster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzzFaster & Greater Messaging System HornetQ zzz
Faster & Greater Messaging System HornetQ zzz
 
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
High Performance Distributed TensorFlow with GPUs - TensorFlow Chicago Meetup...
 
Service workers - Velocity 2016 Training
Service workers - Velocity 2016 TrainingService workers - Velocity 2016 Training
Service workers - Velocity 2016 Training
 
The HTML5 WebSocket API
The HTML5 WebSocket APIThe HTML5 WebSocket API
The HTML5 WebSocket API
 
I know why your Java is slow
I know why your Java is slowI know why your Java is slow
I know why your Java is slow
 
Mobile web performance - MoDev East
Mobile web performance - MoDev EastMobile web performance - MoDev East
Mobile web performance - MoDev East
 
HAProxy tech talk
HAProxy tech talkHAProxy tech talk
HAProxy tech talk
 

Ähnlich wie Perl comet

DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...
DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...
DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...Aman Kohli
 
Easy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDEEasy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDEJBUG London
 
Nodejs Performance Debug
Nodejs Performance DebugNodejs Performance Debug
Nodejs Performance DebugRafael Gonzaga
 
Practical Operation Automation with StackStorm
Practical Operation Automation with StackStormPractical Operation Automation with StackStorm
Practical Operation Automation with StackStormShu Sugimoto
 
Hand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWebHand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWebSugree Phatanapherom
 
Gpars - the coolest bits
Gpars - the coolest bitsGpars - the coolest bits
Gpars - the coolest bitsArtur Gajowy
 
Expand Your Testing with Virtual Services
Expand Your Testing with Virtual ServicesExpand Your Testing with Virtual Services
Expand Your Testing with Virtual ServicesAmber Race
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testingPerl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testingVlatko Kosturjak
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesciklum_ods
 
Foomo / Zugspitze Presentation
Foomo / Zugspitze PresentationFoomo / Zugspitze Presentation
Foomo / Zugspitze Presentationweareinteractive
 
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Ontico
 
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult CasesPositive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult CasesPositive Hack Days
 
Http Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacksHttp Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacksStefano Di Paola
 
mri ruby gil
mri ruby gilmri ruby gil
mri ruby gilachempion
 
Deploying JRuby Web Applications
Deploying JRuby Web ApplicationsDeploying JRuby Web Applications
Deploying JRuby Web ApplicationsJoe Kutner
 
LogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeLogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeJames Turnbull
 
Serverless orchestration and automation with Cloud Workflows
Serverless orchestration and automation with Cloud WorkflowsServerless orchestration and automation with Cloud Workflows
Serverless orchestration and automation with Cloud WorkflowsMárton Kodok
 
AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and Stefano di P...
AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and  Stefano di P...AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and  Stefano di P...
AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and Stefano di P...Magno Logan
 

Ähnlich wie Perl comet (20)

DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...
DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...
DSLing your System For Scalability Testing Using Gatling - Dublin Scala User ...
 
Easy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDEEasy Integration with Apache Camel and Fuse IDE
Easy Integration with Apache Camel and Fuse IDE
 
Camel overview
Camel overview Camel overview
Camel overview
 
Nodejs Performance Debug
Nodejs Performance DebugNodejs Performance Debug
Nodejs Performance Debug
 
Practical Operation Automation with StackStorm
Practical Operation Automation with StackStormPractical Operation Automation with StackStorm
Practical Operation Automation with StackStorm
 
Hand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWebHand-on Resources II: Extending SCMSWeb
Hand-on Resources II: Extending SCMSWeb
 
AppengineJS
AppengineJSAppengineJS
AppengineJS
 
Gpars - the coolest bits
Gpars - the coolest bitsGpars - the coolest bits
Gpars - the coolest bits
 
Expand Your Testing with Virtual Services
Expand Your Testing with Virtual ServicesExpand Your Testing with Virtual Services
Expand Your Testing with Virtual Services
 
Perl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testingPerl Usage In Security and Penetration testing
Perl Usage In Security and Penetration testing
 
Rapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devicesRapid java backend and api development for mobile devices
Rapid java backend and api development for mobile devices
 
Foomo / Zugspitze Presentation
Foomo / Zugspitze PresentationFoomo / Zugspitze Presentation
Foomo / Zugspitze Presentation
 
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)Mасштабирование микросервисов на Go, Matt Heath (Hailo)
Mасштабирование микросервисов на Go, Matt Heath (Hailo)
 
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult CasesPositive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
Positive Hack Days. Goltsev. Web Vulnerabilities: Difficult Cases
 
Http Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacksHttp Parameter Pollution, a new category of web attacks
Http Parameter Pollution, a new category of web attacks
 
mri ruby gil
mri ruby gilmri ruby gil
mri ruby gil
 
Deploying JRuby Web Applications
Deploying JRuby Web ApplicationsDeploying JRuby Web Applications
Deploying JRuby Web Applications
 
LogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesomeLogStash - Yes, logging can be awesome
LogStash - Yes, logging can be awesome
 
Serverless orchestration and automation with Cloud Workflows
Serverless orchestration and automation with Cloud WorkflowsServerless orchestration and automation with Cloud Workflows
Serverless orchestration and automation with Cloud Workflows
 
AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and Stefano di P...
AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and  Stefano di P...AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and  Stefano di P...
AppSec EU 2009 - HTTP Parameter Pollution by Luca Carettoni and Stefano di P...
 

Mehr von Marian Marinov

Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingMarian Marinov
 
Basic presentation of cryptography mechanisms
Basic presentation of cryptography mechanismsBasic presentation of cryptography mechanisms
Basic presentation of cryptography mechanismsMarian Marinov
 
Microservices: Benefits, drawbacks and are they for me?
Microservices: Benefits, drawbacks and are they for me?Microservices: Benefits, drawbacks and are they for me?
Microservices: Benefits, drawbacks and are they for me?Marian Marinov
 
Introduction and replication to DragonflyDB
Introduction and replication to DragonflyDBIntroduction and replication to DragonflyDB
Introduction and replication to DragonflyDBMarian Marinov
 
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMessage Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMarian Marinov
 
How to successfully migrate to DevOps .pdf
How to successfully migrate to DevOps .pdfHow to successfully migrate to DevOps .pdf
How to successfully migrate to DevOps .pdfMarian Marinov
 
How to survive in the work from home era
How to survive in the work from home eraHow to survive in the work from home era
How to survive in the work from home eraMarian Marinov
 
Improve your storage with bcachefs
Improve your storage with bcachefsImprove your storage with bcachefs
Improve your storage with bcachefsMarian Marinov
 
Control your service resources with systemd
 Control your service resources with systemd  Control your service resources with systemd
Control your service resources with systemd Marian Marinov
 
Comparison of-foss-distributed-storage
Comparison of-foss-distributed-storageComparison of-foss-distributed-storage
Comparison of-foss-distributed-storageMarian Marinov
 
Защо и как да обогатяваме знанията си?
Защо и как да обогатяваме знанията си?Защо и как да обогатяваме знанията си?
Защо и как да обогатяваме знанията си?Marian Marinov
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL serverMarian Marinov
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKMarian Marinov
 
Challenges with high density networks
Challenges with high density networksChallenges with high density networks
Challenges with high density networksMarian Marinov
 
SiteGround building automation
SiteGround building automationSiteGround building automation
SiteGround building automationMarian Marinov
 
Preventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel trackingPreventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel trackingMarian Marinov
 
Managing a lot of servers
Managing a lot of serversManaging a lot of servers
Managing a lot of serversMarian Marinov
 
Let's Encrypt failures
Let's Encrypt failuresLet's Encrypt failures
Let's Encrypt failuresMarian Marinov
 

Mehr von Marian Marinov (20)

Dev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & LoggingDev.bg DevOps March 2024 Monitoring & Logging
Dev.bg DevOps March 2024 Monitoring & Logging
 
Basic presentation of cryptography mechanisms
Basic presentation of cryptography mechanismsBasic presentation of cryptography mechanisms
Basic presentation of cryptography mechanisms
 
Microservices: Benefits, drawbacks and are they for me?
Microservices: Benefits, drawbacks and are they for me?Microservices: Benefits, drawbacks and are they for me?
Microservices: Benefits, drawbacks and are they for me?
 
Introduction and replication to DragonflyDB
Introduction and replication to DragonflyDBIntroduction and replication to DragonflyDB
Introduction and replication to DragonflyDB
 
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQMessage Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
Message Queuing - Gearman, Mosquitto, Kafka and RabbitMQ
 
How to successfully migrate to DevOps .pdf
How to successfully migrate to DevOps .pdfHow to successfully migrate to DevOps .pdf
How to successfully migrate to DevOps .pdf
 
How to survive in the work from home era
How to survive in the work from home eraHow to survive in the work from home era
How to survive in the work from home era
 
Managing sysadmins
Managing sysadminsManaging sysadmins
Managing sysadmins
 
Improve your storage with bcachefs
Improve your storage with bcachefsImprove your storage with bcachefs
Improve your storage with bcachefs
 
Control your service resources with systemd
 Control your service resources with systemd  Control your service resources with systemd
Control your service resources with systemd
 
Comparison of-foss-distributed-storage
Comparison of-foss-distributed-storageComparison of-foss-distributed-storage
Comparison of-foss-distributed-storage
 
Защо и как да обогатяваме знанията си?
Защо и как да обогатяваме знанията си?Защо и как да обогатяваме знанията си?
Защо и как да обогатяваме знанията си?
 
Securing your MySQL server
Securing your MySQL serverSecuring your MySQL server
Securing your MySQL server
 
Sysadmin vs. dev ops
Sysadmin vs. dev opsSysadmin vs. dev ops
Sysadmin vs. dev ops
 
DoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDKDoS and DDoS mitigations with eBPF, XDP and DPDK
DoS and DDoS mitigations with eBPF, XDP and DPDK
 
Challenges with high density networks
Challenges with high density networksChallenges with high density networks
Challenges with high density networks
 
SiteGround building automation
SiteGround building automationSiteGround building automation
SiteGround building automation
 
Preventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel trackingPreventing cpu side channel attacks with kernel tracking
Preventing cpu side channel attacks with kernel tracking
 
Managing a lot of servers
Managing a lot of serversManaging a lot of servers
Managing a lot of servers
 
Let's Encrypt failures
Let's Encrypt failuresLet's Encrypt failures
Let's Encrypt failures
 

Perl comet

  • 1. Comet implementations for Perl Marian HackMan Marinov Co-founder and CEO of 1H Ltd. mm@1h.com Bulgarian Perl Workshop 2013
  • 2. Replacing browser PULL with server PUSH What is Comet? AJAX Push Reverse AJAX Two-way-web HTTP Streaming HTTP Server Push Bulgarian Perl Workshop 2013
  • 3. Hidden iframe XMLHttpRequest long polling with - AJAX - XMLHttpRequest - Script tag Implementations Bulgarian Perl Workshop 2013
  • 5. Iframe sent as Hidden iframe chunked blcok Infinitely long Works on every browser Lacks reliable error handling Connection state unavailable Bulgarian Perl Workshop 2013
  • 6. hackman@gamelon:~$ curl http://localhost:4670/push/12345/iframe/channel1 <html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" <meta http-equiv="Cache-Control" content="no-store"> <meta http-equiv="Cache-Control" content="no-cache"> <meta http-equiv="Pragma" content="no-cache"> <meta http-equiv="Expires" content="Thu, 1 Jan 1970 00:00:00 GMT"> </head> <body> <script>document.getElementById('counter').innerHTML = '1';</script> <script>document.getElementById('counter').innerHTML = '2';</script> <script>document.getElementById('counter').innerHTML = '3';</script> <script>document.getElementById('counter').innerHTML = '4';</script> <script>document.getElementById('counter').innerHTML = '5';</script> <script>document.getElementById('counter').innerHTML = '6';</script> <html> <head> <title>Comet test Page</title> </head> <body> <h2 align="center">My counter: </h2> <span id='counter'></span> <iframe href='http://localhost:8000' height=0 width=0></iframe> </body> </html> Bulgarian Perl Workshop 2013
  • 7. XMLHttpRequest Content-type: multipart/x-mixed-replace; boundary=NEXTPARTrnrn The Ajax way of using Comet Reliable connection handling Connection state information Bulgarian Perl Workshop 2013
  • 8. hackman@gamelon:~$ curl http://localhost:8000/ --NEXTPART Content-type: text/plain <script>document.getElementById('counter').innerHTML = '0';</script> --NEXTPART Content-type: text/plain <script>document.getElementById('counter').innerHTML = '1';</script> --NEXTPART Content-type: text/plain <script>document.getElementById('counter').innerHTML = '2';</script> --NEXTPART Bulgarian Perl Workshop 2013
  • 9. Long Polling XMLHttpRequest - creates a request - when all data is received - creates subsequent request Bulgarian Perl Workshop 2013
  • 10. Long Polling <script> tag - creates a script tag - when all data is received - creates new script tag Bulgarian Perl Workshop 2013
  • 11. Meteor Stardust Frameworks: - Mojolicious - PSGI - Continuity What Comet implementations we have in Perl Bulgarian Perl Workshop 2013
  • 12. http://meteorserver.org/ Meteor Stand alone web server Supports: - iframe - xhrinteractive - simplepoll & smartpoll - longpoll - flash & flashloadvars Bulgarian Perl Workshop 2013
  • 13. Event controller commands ADDMESSAGE chan msg COUNTSUBSCRIBERS chan LISTCHANNELS SHOWSTATS QUIT Bulgarian Perl Workshop 2013
  • 14. hackman@gamelon:~/Comet$ nc localhost 4671 SHOWSTATS OK uptime: 279 channel_count: 0 subscriber_connections_accepted: 3 controller_connections_accepted: 1 total_inbound_bytes: 524 total_outbound_bytes: 646 documents_not_found: 3 current_controllers: 1 total_requests: 4 current_subscribers: 0 --EOT-- ADDMESSAGE channel1 testing OK 0 LISTCHANNELS OK channel1(1/0) --EOT-- ADDMESSAGE channel1 dddddd OK 1 Bulgarian Perl Workshop 2013
  • 15. $ curl http://localhost:4670/push/12345/iframe/channel1 <html><head> <script type="text/javascript"> window.onError = null; var domainparts = document.domain.split("."); document.domain = domainparts[domainparts.length-2]+". "+domainparts[domainparts.length-1]; parent.Meteor.register(this); </script> </head> <body onload="try { parent.Meteor.reset(this) } catch (e) {}"> <script>ch("channel1", 1);</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(2,"channel1","fufufu");</script> <script>p(-1,"");</script> ^C hackman@gamelon:~$ Bulgarian Perl Workshop 2013
  • 16. $ curl http://localhost:4670/push/12345/xhrinteractive/channel1 ............................................................................................................. ............................................................................................................. ............................................................................................................. ............................................................................................................. ............................................................................................................. ......................................... <script>ch("channel1", 2);</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(3,"channel1","s1dasda");</script> <script>p(-1,"");</script> <script>p(-1,"");</script> ^C hackman@gamelon:~$ Bulgarian Perl Workshop 2013
  • 17. $ curl http://localhost:4670/push/12345/simplepoll/channel1 <script>ch("channel1", 3);</script> hackman@gamelon:~$ $ curl http://localhost:4670/push/12345/smartpoll/channel1 <script>ch("channel1", 3);</script> hackman@gamelon:~$ $ curl http://localhost:4670/push/12345/longpoll/channel1 <script>ch("channel1", 3);</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(-1,"");</script> <script>p(4,"channel1","gtwedsada");</script> hackman@gamelon:~$ Bulgarian Perl Workshop 2013
  • 18. Stand alone web server Almost no documentation Stardust No updates since 2011 Supports: stream and longpoll remove With::Log from stardust.pl cpan Stardust Bulgarian Perl Workshop 2013
  • 19. $ curl -d 'm={ "type": "Test", "data": [1,2,3] }' http://localhost:5742/channel/foo/stream/foo/ /channel/foo/stream/foo/ not found.[root@gamelon script]# hackman@gamelon:~$ $ curl -d 'm={ "type": "Test", "data": [1,2,3] }' http://localhost:5742/channel/foo $ curl http://localhost:5742/channel/foo [{"messages":[{"_ts":1360399562.89221,"data":[1,2,3],"type":"Test","_ch":"foo"}], "name":"foo","subscribers":[],"size":8,"i":1}] hackman@gamelon:~$ $ curl -d 'm={ "type": "Test", "data": [2,3] }' http://localhost:5742/channel/foo $ curl http://localhost:5742/channel/foo [{"messages":[{"_ts":1360399562.89221,"data":[1,2,3],"type":"Test","_ch":"foo"}, {"_ts":1360399605.81986,"data":[2,3],"type":"Test","_ch":"foo"}], "name":"foo","subscribers":[],"size":8,"i":2}] Bulgarian Perl Workshop 2013
  • 20. Other Perl comet implementations: - POE-Component-Server-Bayeux - Tatsumaki Additional readings: http://toroid.org/ams/etc/mojolicious-http-streaming http://infrequently.org/2006/03/comet-low-latency-data-for-the-browser/ http://showmetheco.de/articles/2011/2/diving-into-html5-with-websockets-and-perl.html Bulgarian Perl Workshop 2013
  • 21. More on the subject here: http://www.slideshare.net/simon/time-for-comet ? ? ? ? ? ? ? ? My slides can be found here: ? http://www.slideshare.net/azilian/perl-comet Bulgarian Perl Workshop 2013

Hinweis der Redaktion

  1. A lot of names for the same technology :)
  2. Streaming Short polling Long polling
  3. Does not support cross domain access Before IE needs minimum 256bytes of data before executing anything The same issue is present in Safari
  4. x-mixed-replace is invented by Netscape 1995 since 2004 has support in Gecko browsers it is also included in IE 10 and newer Does not support cross domain access
  5. Does not support cross domain access Works on all browsers
  6. Supports cross domain access Works on all browsers
  7. You can do it with CGI.pm but it is not advisable
  8. You can do it with CGI.pm but it is not advisable
  9. You can do it with CGI.pm but it is not advisable
  10. You can do it with CGI.pm but it is not advisable
  11. You can do it with CGI.pm but it is not advisable
  12. You can do it with CGI.pm but it is not advisable
  13. You can do it with CGI.pm but it is not advisable
  14. You can do it with CGI.pm but it is not advisable
  15. You can do it with CGI.pm but it is not advisable
  16. You can do it with CGI.pm but it is not advisable
  17. You can do it with CGI.pm but it is not advisable