If you write web apps in Perl (perhaps using Catalyst, Mojolicious, Dancer, or one of the other great web frameworks), you are probably already using PSGI, but do you understand how it works and why PSGI is so amazing? You should! If you still write web apps using CGI, then there are many reasons why you should create your next project using a PSGI-compatible web framework.
PSGI is a specification, like CGI, that describes how web apps and web servers can communicate. It stands for Perl web Server Gateway Interface, and the first version of the specification was published to the CPAN on Oct 13, 2009.
This talk will go over:
* what PSGI is and how it works,
* how it differs and is better than CGI,
* what makes it so cool,
* and how you can use it to do awesome things.
You'll get the most out of this talk if you already know Perl and use it to build web applications.
If you write web apps in Perl (perhaps using Catalyst, Mojolicious, Dancer, or one of the other great web frameworks), you are probably already using PSGI, but do you understand how it works and why PSGI is so amazing? You should! If you still write web apps using CGI, then there are many reasons why you should create your next project using a PSGI-compatible web framework.
PSGI is a specification, like CGI, that describes how web apps and web servers can communicate. It stands for Perl web Server Gateway Interface, and the first version of the specification was published to the CPAN on Oct 13, 2009.
This talk will go over:
* what PSGI is and how it works,
* how it differs and is better than CGI,
* what makes it so cool,
* and how you can use it to do awesome things.
You'll get the most out of this talk if you already know Perl and use it to build web applications.
This document discusses ngx_mod_psgi, which allows running PSGI applications within the nginx web server. It provides an overview of how PSGI applications can access standard environment variables and input streams. It also mentions some PSGI extensions for debugging, logging, and sessions. Finally, it thanks the audience and provides a link to the GitHub repository for ngx_mod_psgi.
This document introduces the Web::Scraper module for Perl, which provides a more robust and maintainable way to scrape web pages compared to regular expressions. Web::Scraper uses a DSL to select elements and extract data via CSS or XPath selectors. It returns structured data like URLs, text, and name-value pairs from selected elements. The document provides examples of scraping timestamps, links, and lists of sites to demonstrate how Web::Scraper works and its advantages over traditional scraping with regular expressions.
Keep hearing about Plack and PSGI, and not really sure what they're for, and why they're popular? Maybe you're using Plack at work, and you're still copying-and-pasting `builder` lines in to your code without really knowing what's going on? What's the relationship between Plack, PSGI, and CGI? Plack from first principles works up from how CGI works, the evolution that PSGI represents, and how Plack provides a user-friendly layer on top of that.
Apache::LogFormat::Compiler YAPC::Asia 2013 Tokyo LT-ThonMasahiro Nagano
This story describes the development of the Apache::LogFormat::Compiler (ALFC) module by an operations engineer to optimize logging performance in a web application. The original PM::AccessLog module was identified as a performance bottleneck by profiling tools. Several optimizations were tried, including the PM::AxsLog middleware, but it only supported fixed log formats. The operations engineer then created ALFC to compile log formats to Perl code for improved performance. It allowed the AxsLog middleware to be updated, achieving a 5x performance gain in logging. This addressed the original developer's need to customize log formats and store additional fields in logs.
PSGI is a Perl port of Python's WSGI and Ruby's Rack that defines a common interface between web servers and frameworks. Plack provides reference implementations of PSGI servers as well as middleware and utilities. This allows frameworks to run on many servers like standalone, FastCGI, and Apache using a common PSGI application interface. Plack is fast, supports many frameworks through adapters, and provides tools like Plackup and middleware to help build and test PSGI applications.
This document provides instructions for installing and configuring mod_perl on an Apache web server. It begins with steps to download, compile and install mod_perl. It then discusses configuring Apache's httpd.conf file to load the perl module and set the handler. Benchmark tests show that a hello world script runs over 15 times faster under mod_perl than CGI. The document encourages switching to mod_perl for improved performance and lower server loads. It presents mod_perl as a simple upgrade that makes existing Perl-based websites run faster and more efficiently.
This document summarizes a presentation about managing CPAN dependencies for web development projects. It describes a case study where a developer installed many CPAN modules for a new web app, but ran into problems with dependency and versioning issues during deployment to production servers. The presenter then introduced their solution called Carton, a tool for creating isolated, local Perl environments for apps and locking dependency versions to allow reproducible, stable deployments across different machines. Key features discussed included dependency declaration, isolated environments, version control, analysis and more. The document concludes with a call for questions and thanks.
Two years ago, Spotify introduced Scio, an open-source Scala framework to develop data pipelines and deploy them on Google Dataflow. In this talk, we will discuss the evolution of Scio, and share the highlights of running Scio in production for two years. We will showcase several interesting data processing workflows ran at Spotify, what we learned from running them in production, and how we leveraged that knowledge to make Scio faster, and safer and easier to use.
Rhebok, High Performance Rack Handler / Rubykaigi 2015Masahiro Nagano
This document discusses Rhebok, a high performance Rack handler written in Ruby. Rhebok uses a prefork architecture for concurrency and achieves 1.5-2x better performance than Unicorn. It implements efficient network I/O using techniques like IO timeouts, TCP_NODELAY, and writev(). Rhebok also uses the ultra-fast PicoHTTPParser for HTTP request parsing. The document provides an overview of Rhebok, benchmarks showing its performance, and details on its internals and architecture.
This document discusses strategies for optimizing access to large "master data" files in PHP applications. It describes converting master data files from PHP arrays to tab-separated value (TSV) files to reduce loading time. Benchmark tests show the TSV format reduces file size by over 50% and loading time from 70 milliseconds to 7 milliseconds without OPcache. Accessing rows as arrays by splitting on tabs is 3 times slower but still very fast at over 350,000 gets per second. The TSV optimization has been used successfully in production applications.
Stream processing in Mercari - Devsumi 2015 autumn LTMasahiro Nagano
This document discusses Mercari's use of stream processing to monitor logs and metrics. It describes how Mercari previously used scripts to parse logs periodically, which was inefficient. Mercari now uses Norikra, an open source stream processing tool, to ingest logs and metrics in real-time and perform analytics using SQL queries. Norikra provides benefits over their previous approach like no need to restart processes and the ability for any engineer to write SQL queries. The results are then sent to monitoring tools like Mackerel for alerting and graphing.
Gazelle - Plack Handler for performance freaks #yokohamapmMasahiro Nagano
1) Gazelle is a fast PSGI/Plack HTTP server written in Perl and C code.
2) Benchmarks show it can handle 3x more requests per second than other servers for simple applications.
3) Its speed comes from optimizations like using accept4, writev system calls, and being written mostly in fast C code via XS.
This document discusses the memory usage of Perl-based web applications running in a multi-process prefork model with MaxRequestsPerChild configuration. It notes that this model ensures memory is reliably freed when processes exit after fulfilling a set number of requests. It allows for temporary large memory allocations or memory leaks to be tolerated. The operator needs to monitor for irregular increases in memory usage and respond accordingly.
This document discusses several Perl modules:
- Time::Crontab parses crontab date and time fields. Proclet supports cron-like jobs.
- Apache::LogFormat::Compiler had issues with daylight saving time changes but version 0.14 and higher fixed this.
- POSIX::strftime::Compiler was created to avoid issues with locales affecting strftime outputs.
- Modules like Time::TZOffset, HTTP::Entity::Parser, WWW::Form::UrlEncoded, and WWW::Form::UrlEncoded::XS were created with performance improvements over existing solutions. Benchmark results showed the XS implementations having significantly better performance.
IoT Devices Compliant with JC-STAR Using Linux as a Container OSTomohiro Saneyoshi
Security requirements for IoT devices are becoming more defined, as seen with the EU Cyber Resilience Act and Japan’s JC-STAR.
It's common for IoT devices to run Linux as their operating system. However, adopting general-purpose Linux distributions like Ubuntu or Debian, or Yocto-based Linux, presents certain difficulties. This article outlines those difficulties.
It also, it highlights the security benefits of using a Linux-based container OS and explains how to adopt it with JC-STAR, using the "Armadillo Base OS" as an example.
Feb.25.2025@JAWS-UG IoT
6. Summary of Slide
• Monoceros
• Plack/PSGI Basics
• How to build a high performance
PSGI/Plack server
•
13年11月20日水曜日
Introduction of PSGI servers on CPAN
7. Performance Techniques
for PSGI/Plack server
• Prefork
• no accept serialization
• TCP_DEFER_ACCEPT
• non blocking IO / reduce system calls
• XS HTTP Parser
• TCP_NODELAY
13年11月20日水曜日
18. :unix PerlIO
sub do_accept {
my $self = shift;
use open 'IO' => ':unix';
my ($conn,$peer);
$peer = accept4($conn,$self->{listen_sock});
return ($conn, $peer);
}
13年11月20日水曜日