Inside Bokete: Web Application with Mojolicious and others

Yusuke Wada
Yusuke WadaWeb Application Developer
Inside Bokete:
Web Application with
Mojolicious and others.
Yusuke Wada a.k.a yusukebe
From Yokohama, Japan
2013-06-05
YAPC::NA 2013
Introduction of myself
- Yusuke Wada a.k.a yusukebe
- From Japan, Yokohama.
- A Web Application Enginner.
- CEO of Wadit Inc and CTO of Omoroki Inc.
- I got the award of the YAPC::Asia 2012 popularity vote.
- My trip is supported by Japan Perl Association.
Development of “Bokete”
My work
I spend a time to developing web site named “Bokete”. “Bokete” is my work.
What’s Bokete?
Bokete is Japanese popular entertainment web service like a 9gag.com.
- Japanese entertainment web service by Omoroki Inc.
- It’s like a 9gag.com
Bokete has ...
- Web site for PC browser and smart phone browser
- iOS App and Android App
- 3 hundred million Page View per month overall
- Backend system is written by me
Web site for PC and Smartphone browser, mobile application of iOS / Android are available in
Bokete. We have 3 hundred million page views per month overall. Backend system is written by
me.
http://bokete.jp/
Screenshot of web site
Screenshot of mobile App
Users generate contents
Bokete services
User who has funny things.
Post
See
User who want to laugh.
Bokete have a many contents generated by users. User who has funny things post the “boke” to
Bokete sites. And other users who want to laugh see these contents.
Boke
= Photo + Short Text
What are contents of Bokete?
So, what are contents of the Bokete? The answer is “Boke”. Boke is constructed of a photo and a
short text. Let’s see bokes on Bokete.
Boke No.1
You know, get this calmly.
You are hitting your referee.
Boke No.2
Who forgot a uniform ?
Boke No.3
Hey! You didn’t say UNO!!
Boke No.4
They give up.
Boke No.5
This man is the murderer.
How about bokes?
How about the bokes on Bokete? We have books of Bokete, so please ask me later if you have
interests of bokes. Then I’ll introduce backend system of Bokete.
System of Bokete
About using Perl
Technical topics
Bokete is made by Perl! We love Perl.
Structure of servers
Web App
EC2 Instances
Elastic Load Blancing
RDS
MySQL Master
RDS
MySQL Read Replica
API App
EC2 Instances
Elastic Load Blancing
Memcached Memcached
Browsers Mobile Apps
Using Mojolicious!
- Mojolicious as a Web Application Framework
- But Mojolicious is very “thin” not like a Ruby on Rails
- So, we should use other CPAN modules
- Many modules written by Japanese author are used
We use Mojolicious to implementing Bokete. Mojolicious is good Web Application Framework. But,
Mojolicious is very “thin” and too simple that is not like a Ruby on Rails. So, inside Bokete,
we use other CPAN modules that are written by Japanese Author. I think these modules are not so
popular in overseas from Japan. One of this talk theme is introduce Japanese CPAN modules.
PSGI/Plack
Interface between app and server
Enable to use Plack Middlewares and Starman/Starlet
as high-perfomance app server
PSGI
Web App
Web Application
Framework
Web Server
supports PSGI
Web App
Web Application
Framework
Web App
Web Application
Framework
Web Server
supports PSGI
Web Server
supports PSGI
Plack
Middleware
“.psgi” example
use Mojo::Server::PSGI;
use Plack::Builder;
use Bokete::Web;
my $psgi = Mojo::Server::PSGI->new( app => Bokete::Web->new );
my $app = $psgi->to_psgi_app;
builder {
enable "Runtime";
enable "ServerStatus::Lite",
path => '/server-status',
allow => [ '0.0.0.0/1' ],
scoreboard => '/var/run/server';
$psgi->to_psgi_app;
};
Add X-Runtime Header
It’s like a Apache’s mod_status
Mouse
Fast class builder
package Point;
use Mouse;
has 'x' => (is => 'rw', isa => 'Int');
has 'y' => (is => 'rw', isa => 'Int');
sub clear {
my($self) = @_;
$self->x(0);
$self->y(0);
}
1;
Moose compatible, Fast because using XS
and No dependencies.
DBIx::Skinny or Teng
Minimal O/R mapper
Supporting transaction, raw SQL, inflate/deflate
lightweight, and fast
Prepare your database on SQLite or MySQL, others.
package MyDB;
use DBIx::Skinny;
1;
Make some modules for Database access.
*Teng is newer version of DBIx::Skinny
Using DBIx::Skinny
use MyDB;
my $db = MyDB->new({ connect_info => [ 'dbi:SQLite:' ] });
$db->insert('table', { col => 'value' }); # Insert
my $row = $db->single('table', { id => 1 }); # Select
say $row->col;
my $iter = $db->search('table'); # Iterator instance
while ($row = $iter->next) {
say $row->col;
}
package MyDB::Schema;
use DBIx::Skinny::Schema;
install_table ‘table’ => schema {
pk ‘id’;
columns qw/id col/;
};
1;
FormValidator::Lite
A form validator
FormValidator::Lite->load_constraints(qw/Japanese Email/);
my $validator = FormValidator::Lite->new($self->req);
my $res -> $validator->check(
name => [qw/NOT_NULL/],
mail => [qw/EMAIL/],
{ mails => [qw/mail mail_confirm/] } => ['DUPLICATION']
);
if($validator->has_error) {
$self->stash->{messages} = $validator->get_error_messages();
return $self->render;
}
...;
Fast, simple, customizing error messages
HTML::FillInForm::Lite
fill HTML forms with Perl data
$self->helper(
render_fill => sub {
my ( $self, $template_name ) = @_;
my $html = $self->render_partial($template_name)->to_string;
return $self->render_text(
HTML::FillInForm::Lite->fill( $html, $self->req->params ),
format => 'html'
);
}
);
2 times faster than HTML::FillInForm
# In controller
return $self->render_fill(‘/post’) if $error;
HTML form is filled with request parameters
Shortcut method for controller
- Check request parameters
- Show error messages
- Fill HTML form with request parameters
sub post {
my $self = shift;
if($self->form('Post')->has_error) {
return $self->render_fill('/post');
}
}
Devel::KYTProf
Profiler for I/O blocking time
use Devel::KYTProf;
Carton / v0.9.15
Manager of Perl modules
Like a ruby bundler, using cpanfile
Carton manages
dependency of modules.
CPAN
modules
in App
An environment No.1
CPAN
modules
in App
An environment No.2
Same version modules
Carton is now
experimetal !
API is likely to chage.
Using Carton.
# on cpanfile
requires ‘Mojolicious’, 4.07;
requires ‘Mouse’;
requires ‘Teng’, 0.18;
$ carton install
$ carton exec -Ilib -- plackup myapp.psgi
carton.lock file is generated
and module files is installed into “local” directory
Execute perl command with core libraries and local libraries
Server::Starter
Daemon for hot-deploying
# On daemontools run script
start_server --port 8001 -- plackup -s Starman bokete_web.psgi
Supporting Starman/Starlet and other HTTP servers
$ sudo svc -h /service/bokete_web
To gracefully restart the server program,
sending SIGHUP to this daemon.
Cinnamon
Simple deployment tool
use Cinnamon::DSL;
set repository => 'git@github.com:yusukebe/MyApp.git';
role 'web' => [qw/001.server.name 002.server.name/],
{ deploy_to => '/home/user/www/myapp', branch => 'master', damoentools_dir => '/service/myapp' };
task deploy => {
setup => sub {
my ($host, @args) = @_;
my $repository = get('repository');
my $deploy_to = get('deploy_to');
my $branch = 'origin/' . get('branch');
remote {
run "git clone $repository $deploy_to && cd $deploy_to && git checkout -q $branch";
} $host;
}
};
$ cinnamon web deploy:setup
And many other modules
- Data::Validator - Validator for Perl data
- CloudForecast - Web Application for server monitoring
- Data::Page::Navigation - Pager
- Test::mysqld
- Plack::Middleware::ReverseProxy
- Plack::Middleware::AxsLog
- Starman
Bokete is supported by many CPAN Modules
Mojolicious is good but minimal.
We combine CPAN modules which is choosed.
It’s like LEGO blocks !!
Wrap-up
- I’ve talk about...
- Bokete as a Japanese entertainment web site
- We are using a Mojolicious !!
- Other CPAN modules by Japanese authors
- There is more than one way to develop web applications !!
And ...
YAPC::Asia 2013 will be held !
- September 19 - 21 on Keio University near the Tokyo .
- Early Bird Tickets On Sale ! - 1,000 JPY discounted .
- Talk submissions are accepted now .
- Most biggest YAPC in the world (Maybe) .
Thank you !!
1 of 37

Recommended

Developing apps using Perl by
Developing apps using PerlDeveloping apps using Perl
Developing apps using PerlAnatoly Sharifulin
1.4K views87 slides
Mojo as a_client by
Mojo as a_clientMojo as a_client
Mojo as a_clientMarcus Ramberg
1.7K views52 slides
RESTful web services by
RESTful web servicesRESTful web services
RESTful web servicesTudor Constantin
2K views13 slides
Perl web frameworks by
Perl web frameworksPerl web frameworks
Perl web frameworksdiego_k
670 views103 slides
Web Apps in Perl - HTTP 101 by
Web Apps in Perl - HTTP 101Web Apps in Perl - HTTP 101
Web Apps in Perl - HTTP 101hendrikvb
2.9K views29 slides
Mojolicious - A new hope by
Mojolicious - A new hopeMojolicious - A new hope
Mojolicious - A new hopeMarcus Ramberg
12.1K views98 slides

More Related Content

What's hot

Mojolicious. Веб в коробке! by
Mojolicious. Веб в коробке!Mojolicious. Веб в коробке!
Mojolicious. Веб в коробке!Anatoly Sharifulin
789 views92 slides
Keeping it small - Getting to know the Slim PHP micro framework by
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro frameworkJeremy Kendall
9.6K views214 slides
Mojolicious: what works and what doesn't by
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn'tCosimo Streppone
2.7K views12 slides
Asynchronous programming patterns in Perl by
Asynchronous programming patterns in PerlAsynchronous programming patterns in Perl
Asynchronous programming patterns in Perldeepfountainconsulting
3.6K views115 slides
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk) by
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Dotan Dimet
1.4K views32 slides
Mojolicious on Steroids by
Mojolicious on SteroidsMojolicious on Steroids
Mojolicious on SteroidsTudor Constantin
3.8K views15 slides

What's hot(20)

Keeping it small - Getting to know the Slim PHP micro framework by Jeremy Kendall
Keeping it small - Getting to know the Slim PHP micro frameworkKeeping it small - Getting to know the Slim PHP micro framework
Keeping it small - Getting to know the Slim PHP micro framework
Jeremy Kendall9.6K views
Mojolicious: what works and what doesn't by Cosimo Streppone
Mojolicious: what works and what doesn'tMojolicious: what works and what doesn't
Mojolicious: what works and what doesn't
Cosimo Streppone2.7K views
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk) by Dotan Dimet
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Mojolicious - Perl Framework for the Real-Time Web (Lightning Talk)
Dotan Dimet1.4K views
Slim RedBeanPHP and Knockout by Vic Metcalfe
Slim RedBeanPHP and KnockoutSlim RedBeanPHP and Knockout
Slim RedBeanPHP and Knockout
Vic Metcalfe4K views
Keeping it small: Getting to know the Slim micro framework by Jeremy Kendall
Keeping it small: Getting to know the Slim micro frameworkKeeping it small: Getting to know the Slim micro framework
Keeping it small: Getting to know the Slim micro framework
Jeremy Kendall111.2K views
Perl: Hate it for the Right Reasons by Matt Follett
Perl: Hate it for the Right ReasonsPerl: Hate it for the Right Reasons
Perl: Hate it for the Right Reasons
Matt Follett1K views
Mojolicious, real-time web framework by taggg
Mojolicious, real-time web frameworkMojolicious, real-time web framework
Mojolicious, real-time web framework
taggg1.6K views
Keeping it Small: Getting to know the Slim Micro Framework by Jeremy Kendall
Keeping it Small: Getting to know the Slim Micro FrameworkKeeping it Small: Getting to know the Slim Micro Framework
Keeping it Small: Getting to know the Slim Micro Framework
Jeremy Kendall1.8K views
Building Modern and Secure PHP Applications – Codementor Office Hours with Be... by Arc & Codementor
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Building Modern and Secure PHP Applications – Codementor Office Hours with Be...
Arc & Codementor11.2K views
YAPC::Asia 2010 Twitter解析サービス by Yusuke Wada
YAPC::Asia 2010 Twitter解析サービスYAPC::Asia 2010 Twitter解析サービス
YAPC::Asia 2010 Twitter解析サービス
Yusuke Wada1.8K views
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery by Tatsuhiko Miyagawa
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQueryRemedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Remedie: Building a desktop app with HTTP::Engine, SQLite and jQuery
Tatsuhiko Miyagawa39.1K views
Blog Hacks 2011 by Yusuke Wada
Blog Hacks 2011Blog Hacks 2011
Blog Hacks 2011
Yusuke Wada2.7K views
AnyMQ, Hippie, and the real-time web by clkao
AnyMQ, Hippie, and the real-time webAnyMQ, Hippie, and the real-time web
AnyMQ, Hippie, and the real-time web
clkao2.7K views
A reviravolta do desenvolvimento web by Wallace Reis
A reviravolta do desenvolvimento webA reviravolta do desenvolvimento web
A reviravolta do desenvolvimento web
Wallace Reis932 views
Extending the WordPress REST API - Josh Pollock by Caldera Labs
Extending the WordPress REST API - Josh PollockExtending the WordPress REST API - Josh Pollock
Extending the WordPress REST API - Josh Pollock
Caldera Labs4.9K views

Similar to Inside Bokete: Web Application with Mojolicious and others

rails.html by
rails.htmlrails.html
rails.htmltutorialsruby
501 views11 slides
rails.html by
rails.htmlrails.html
rails.htmltutorialsruby
332 views11 slides
Habitat hack slides - Infracoders Meetup Graz by
Habitat hack slides - Infracoders Meetup GrazHabitat hack slides - Infracoders Meetup Graz
Habitat hack slides - Infracoders Meetup GrazInfralovers
305 views62 slides
Mojolicious by
MojoliciousMojolicious
MojoliciousMarcus Ramberg
4.4K views56 slides
Hack Rio/OS by
Hack Rio/OSHack Rio/OS
Hack Rio/OSKishore Neelamegam
253 views60 slides
node.js: Javascript's in your backend by
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backendDavid Padbury
12.6K views109 slides

Similar to Inside Bokete: Web Application with Mojolicious and others(20)

Habitat hack slides - Infracoders Meetup Graz by Infralovers
Habitat hack slides - Infracoders Meetup GrazHabitat hack slides - Infracoders Meetup Graz
Habitat hack slides - Infracoders Meetup Graz
Infralovers305 views
node.js: Javascript's in your backend by David Padbury
node.js: Javascript's in your backendnode.js: Javascript's in your backend
node.js: Javascript's in your backend
David Padbury12.6K views
RoR (Ruby on Rails) by scandiweb
RoR (Ruby on Rails)RoR (Ruby on Rails)
RoR (Ruby on Rails)
scandiweb2.5K views
Work Queues by ciconf
Work QueuesWork Queues
Work Queues
ciconf8.2K views
DATABASE AUTOMATION with Thousands of database, monitoring and backup by Saewoong Lee
DATABASE AUTOMATION with Thousands of database, monitoring and backupDATABASE AUTOMATION with Thousands of database, monitoring and backup
DATABASE AUTOMATION with Thousands of database, monitoring and backup
Saewoong Lee1.2K views
Ruby on Rails survival guide of an aged Java developer by gicappa
Ruby on Rails survival guide of an aged Java developerRuby on Rails survival guide of an aged Java developer
Ruby on Rails survival guide of an aged Java developer
gicappa1.2K views
Gearman and CodeIgniter by Erik Giberti
Gearman and CodeIgniterGearman and CodeIgniter
Gearman and CodeIgniter
Erik Giberti25.9K views
DiUS Computing Lca Rails Final by Robert Postill
DiUS  Computing Lca Rails FinalDiUS  Computing Lca Rails Final
DiUS Computing Lca Rails Final
Robert Postill587 views
Rails Presentation (Anton Dmitriyev) by True-Vision
Rails Presentation (Anton Dmitriyev)Rails Presentation (Anton Dmitriyev)
Rails Presentation (Anton Dmitriyev)
True-Vision209 views
Using Ember to Make a Bazillion Dollars by Mike Pack
Using Ember to Make a Bazillion DollarsUsing Ember to Make a Bazillion Dollars
Using Ember to Make a Bazillion Dollars
Mike Pack1.1K views
CoffeeScript: A beginner's presentation for beginners copy by Patrick Devins
CoffeeScript: A beginner's presentation for beginners copyCoffeeScript: A beginner's presentation for beginners copy
CoffeeScript: A beginner's presentation for beginners copy
Patrick Devins1.7K views
Deploying your rails application to a clean ubuntu 10 by Maurício Linhares
Deploying your rails application to a clean ubuntu 10Deploying your rails application to a clean ubuntu 10
Deploying your rails application to a clean ubuntu 10
Maurício Linhares3.8K views
Intro to SpringBatch NoSQL 2021 by Slobodan Lohja
Intro to SpringBatch NoSQL 2021Intro to SpringBatch NoSQL 2021
Intro to SpringBatch NoSQL 2021
Slobodan Lohja217 views
Practical Use of MongoDB for Node.js by async_io
Practical Use of MongoDB for Node.jsPractical Use of MongoDB for Node.js
Practical Use of MongoDB for Node.js
async_io19.9K views

More from Yusuke Wada

僕がつくった 70個のうちの48個のWebサービス達 by
僕がつくった 70個のうちの48個のWebサービス達僕がつくった 70個のうちの48個のWebサービス達
僕がつくった 70個のうちの48個のWebサービス達Yusuke Wada
18.8K views121 slides
スッとGoを取り入れる by
スッとGoを取り入れるスッとGoを取り入れる
スッとGoを取り入れるYusuke Wada
23.5K views69 slides
東京脱出計画中 by
東京脱出計画中東京脱出計画中
東京脱出計画中Yusuke Wada
6K views36 slides
Extreme remote working by
Extreme remote workingExtreme remote working
Extreme remote workingYusuke Wada
6.4K views37 slides
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPAN by
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPANPodcastを支える技術、エンジニアのためのWebメディア、そしてCPAN
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPANYusuke Wada
31.3K views105 slides
創造のプロセスを回せ!v0.01 by
創造のプロセスを回せ!v0.01創造のプロセスを回せ!v0.01
創造のプロセスを回せ!v0.01Yusuke Wada
5.8K views26 slides

More from Yusuke Wada(20)

僕がつくった 70個のうちの48個のWebサービス達 by Yusuke Wada
僕がつくった 70個のうちの48個のWebサービス達僕がつくった 70個のうちの48個のWebサービス達
僕がつくった 70個のうちの48個のWebサービス達
Yusuke Wada18.8K views
スッとGoを取り入れる by Yusuke Wada
スッとGoを取り入れるスッとGoを取り入れる
スッとGoを取り入れる
Yusuke Wada23.5K views
東京脱出計画中 by Yusuke Wada
東京脱出計画中東京脱出計画中
東京脱出計画中
Yusuke Wada6K views
Extreme remote working by Yusuke Wada
Extreme remote workingExtreme remote working
Extreme remote working
Yusuke Wada6.4K views
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPAN by Yusuke Wada
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPANPodcastを支える技術、エンジニアのためのWebメディア、そしてCPAN
Podcastを支える技術、エンジニアのためのWebメディア、そしてCPAN
Yusuke Wada31.3K views
創造のプロセスを回せ!v0.01 by Yusuke Wada
創造のプロセスを回せ!v0.01創造のプロセスを回せ!v0.01
創造のプロセスを回せ!v0.01
Yusuke Wada5.8K views
It's not only about "REMOTE" by Yusuke Wada
It's not only about "REMOTE"It's not only about "REMOTE"
It's not only about "REMOTE"
Yusuke Wada2.5K views
事故からはじまるスケールチャンス by Yusuke Wada
事故からはじまるスケールチャンス事故からはじまるスケールチャンス
事故からはじまるスケールチャンス
Yusuke Wada2.8K views
Google BigQueryを使ってみた! by Yusuke Wada
Google BigQueryを使ってみた!Google BigQueryを使ってみた!
Google BigQueryを使ってみた!
Yusuke Wada13.5K views
Webサービスのコンテンツパターン 或いはデータの活⽤ by Yusuke Wada
Webサービスのコンテンツパターン 或いはデータの活⽤Webサービスのコンテンツパターン 或いはデータの活⽤
Webサービスのコンテンツパターン 或いはデータの活⽤
Yusuke Wada7.4K views
とある Perl Monger の働き方 by Yusuke Wada
とある Perl Monger の働き方とある Perl Monger の働き方
とある Perl Monger の働き方
Yusuke Wada15.5K views
5 minutes - YAPC::Asia Tokyo 2014 by Yusuke Wada
5 minutes - YAPC::Asia Tokyo 20145 minutes - YAPC::Asia Tokyo 2014
5 minutes - YAPC::Asia Tokyo 2014
Yusuke Wada2.2K views
Podcastをカジュアルに 支える技術 by Yusuke Wada
Podcastをカジュアルに 支える技術Podcastをカジュアルに 支える技術
Podcastをカジュアルに 支える技術
Yusuke Wada3.4K views
The master plan of scaling a web application by Yusuke Wada
The master plan ofscaling a web applicationThe master plan ofscaling a web application
The master plan of scaling a web application
Yusuke Wada7K views
そのWebサービスは本当に「あたりまえ」だったのか? by Yusuke Wada
そのWebサービスは本当に「あたりまえ」だったのか?そのWebサービスは本当に「あたりまえ」だったのか?
そのWebサービスは本当に「あたりまえ」だったのか?
Yusuke Wada3.3K views
Mojoliciousでつくる! Webアプリ入門 by Yusuke Wada
Mojoliciousでつくる! Webアプリ入門Mojoliciousでつくる! Webアプリ入門
Mojoliciousでつくる! Webアプリ入門
Yusuke Wada22.2K views
10 things to learn from Bokete by Yusuke Wada
10 things to learn from Bokete10 things to learn from Bokete
10 things to learn from Bokete
Yusuke Wada2.5K views
僕らの履歴書 by Yusuke Wada
僕らの履歴書僕らの履歴書
僕らの履歴書
Yusuke Wada4.8K views
僕らがWebサービスをつくる5つの理由 by Yusuke Wada
僕らがWebサービスをつくる5つの理由僕らがWebサービスをつくる5つの理由
僕らがWebサービスをつくる5つの理由
Yusuke Wada53.4K views
僕らがつくるための 「5W」について by Yusuke Wada
僕らがつくるための 「5W」について僕らがつくるための 「5W」について
僕らがつくるための 「5W」について
Yusuke Wada2.6K views

Recently uploaded

TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc
11 views29 slides
Vertical User Stories by
Vertical User StoriesVertical User Stories
Vertical User StoriesMoisés Armani Ramírez
14 views16 slides
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
92 views32 slides
Unit 1_Lecture 2_Physical Design of IoT.pdf by
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdfStephenTec
12 views36 slides
Future of Indian ConsumerTech by
Future of Indian ConsumerTechFuture of Indian ConsumerTech
Future of Indian ConsumerTechKapil Khandelwal (KK)
22 views68 slides
Business Analyst Series 2023 - Week 3 Session 5 by
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5DianaGray10
300 views20 slides

Recently uploaded(20)

TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f... by TrustArc
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc Webinar - Managing Online Tracking Technology Vendors_ A Checklist f...
TrustArc11 views
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... by James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson92 views
Unit 1_Lecture 2_Physical Design of IoT.pdf by StephenTec
Unit 1_Lecture 2_Physical Design of IoT.pdfUnit 1_Lecture 2_Physical Design of IoT.pdf
Unit 1_Lecture 2_Physical Design of IoT.pdf
StephenTec12 views
Business Analyst Series 2023 - Week 3 Session 5 by DianaGray10
Business Analyst Series 2023 -  Week 3 Session 5Business Analyst Series 2023 -  Week 3 Session 5
Business Analyst Series 2023 - Week 3 Session 5
DianaGray10300 views
Voice Logger - Telephony Integration Solution at Aegis by Nirmal Sharma
Voice Logger - Telephony Integration Solution at AegisVoice Logger - Telephony Integration Solution at Aegis
Voice Logger - Telephony Integration Solution at Aegis
Nirmal Sharma39 views
Serverless computing with Google Cloud (2023-24) by wesley chun
Serverless computing with Google Cloud (2023-24)Serverless computing with Google Cloud (2023-24)
Serverless computing with Google Cloud (2023-24)
wesley chun11 views
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ... by Jasper Oosterveld
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
ESPC 2023 - Protect and Govern your Sensitive Data with Microsoft Purview in ...
SAP Automation Using Bar Code and FIORI.pdf by Virendra Rai, PMP
SAP Automation Using Bar Code and FIORI.pdfSAP Automation Using Bar Code and FIORI.pdf
SAP Automation Using Bar Code and FIORI.pdf
Special_edition_innovator_2023.pdf by WillDavies22
Special_edition_innovator_2023.pdfSpecial_edition_innovator_2023.pdf
Special_edition_innovator_2023.pdf
WillDavies2218 views
6g - REPORT.pdf by Liveplex
6g - REPORT.pdf6g - REPORT.pdf
6g - REPORT.pdf
Liveplex10 views

Inside Bokete: Web Application with Mojolicious and others

  • 1. Inside Bokete: Web Application with Mojolicious and others. Yusuke Wada a.k.a yusukebe From Yokohama, Japan 2013-06-05 YAPC::NA 2013
  • 2. Introduction of myself - Yusuke Wada a.k.a yusukebe - From Japan, Yokohama. - A Web Application Enginner. - CEO of Wadit Inc and CTO of Omoroki Inc. - I got the award of the YAPC::Asia 2012 popularity vote. - My trip is supported by Japan Perl Association.
  • 3. Development of “Bokete” My work I spend a time to developing web site named “Bokete”. “Bokete” is my work.
  • 4. What’s Bokete? Bokete is Japanese popular entertainment web service like a 9gag.com. - Japanese entertainment web service by Omoroki Inc. - It’s like a 9gag.com
  • 5. Bokete has ... - Web site for PC browser and smart phone browser - iOS App and Android App - 3 hundred million Page View per month overall - Backend system is written by me Web site for PC and Smartphone browser, mobile application of iOS / Android are available in Bokete. We have 3 hundred million page views per month overall. Backend system is written by me. http://bokete.jp/
  • 8. Users generate contents Bokete services User who has funny things. Post See User who want to laugh. Bokete have a many contents generated by users. User who has funny things post the “boke” to Bokete sites. And other users who want to laugh see these contents.
  • 9. Boke = Photo + Short Text What are contents of Bokete? So, what are contents of the Bokete? The answer is “Boke”. Boke is constructed of a photo and a short text. Let’s see bokes on Bokete.
  • 10. Boke No.1 You know, get this calmly. You are hitting your referee.
  • 11. Boke No.2 Who forgot a uniform ?
  • 12. Boke No.3 Hey! You didn’t say UNO!!
  • 14. Boke No.5 This man is the murderer.
  • 15. How about bokes? How about the bokes on Bokete? We have books of Bokete, so please ask me later if you have interests of bokes. Then I’ll introduce backend system of Bokete.
  • 16. System of Bokete About using Perl Technical topics Bokete is made by Perl! We love Perl.
  • 17. Structure of servers Web App EC2 Instances Elastic Load Blancing RDS MySQL Master RDS MySQL Read Replica API App EC2 Instances Elastic Load Blancing Memcached Memcached Browsers Mobile Apps
  • 18. Using Mojolicious! - Mojolicious as a Web Application Framework - But Mojolicious is very “thin” not like a Ruby on Rails - So, we should use other CPAN modules - Many modules written by Japanese author are used We use Mojolicious to implementing Bokete. Mojolicious is good Web Application Framework. But, Mojolicious is very “thin” and too simple that is not like a Ruby on Rails. So, inside Bokete, we use other CPAN modules that are written by Japanese Author. I think these modules are not so popular in overseas from Japan. One of this talk theme is introduce Japanese CPAN modules.
  • 19. PSGI/Plack Interface between app and server Enable to use Plack Middlewares and Starman/Starlet as high-perfomance app server PSGI Web App Web Application Framework Web Server supports PSGI Web App Web Application Framework Web App Web Application Framework Web Server supports PSGI Web Server supports PSGI Plack Middleware
  • 20. “.psgi” example use Mojo::Server::PSGI; use Plack::Builder; use Bokete::Web; my $psgi = Mojo::Server::PSGI->new( app => Bokete::Web->new ); my $app = $psgi->to_psgi_app; builder { enable "Runtime"; enable "ServerStatus::Lite", path => '/server-status', allow => [ '0.0.0.0/1' ], scoreboard => '/var/run/server'; $psgi->to_psgi_app; }; Add X-Runtime Header It’s like a Apache’s mod_status
  • 21. Mouse Fast class builder package Point; use Mouse; has 'x' => (is => 'rw', isa => 'Int'); has 'y' => (is => 'rw', isa => 'Int'); sub clear { my($self) = @_; $self->x(0); $self->y(0); } 1; Moose compatible, Fast because using XS and No dependencies.
  • 22. DBIx::Skinny or Teng Minimal O/R mapper Supporting transaction, raw SQL, inflate/deflate lightweight, and fast Prepare your database on SQLite or MySQL, others. package MyDB; use DBIx::Skinny; 1; Make some modules for Database access. *Teng is newer version of DBIx::Skinny
  • 23. Using DBIx::Skinny use MyDB; my $db = MyDB->new({ connect_info => [ 'dbi:SQLite:' ] }); $db->insert('table', { col => 'value' }); # Insert my $row = $db->single('table', { id => 1 }); # Select say $row->col; my $iter = $db->search('table'); # Iterator instance while ($row = $iter->next) { say $row->col; } package MyDB::Schema; use DBIx::Skinny::Schema; install_table ‘table’ => schema { pk ‘id’; columns qw/id col/; }; 1;
  • 24. FormValidator::Lite A form validator FormValidator::Lite->load_constraints(qw/Japanese Email/); my $validator = FormValidator::Lite->new($self->req); my $res -> $validator->check( name => [qw/NOT_NULL/], mail => [qw/EMAIL/], { mails => [qw/mail mail_confirm/] } => ['DUPLICATION'] ); if($validator->has_error) { $self->stash->{messages} = $validator->get_error_messages(); return $self->render; } ...; Fast, simple, customizing error messages
  • 25. HTML::FillInForm::Lite fill HTML forms with Perl data $self->helper( render_fill => sub { my ( $self, $template_name ) = @_; my $html = $self->render_partial($template_name)->to_string; return $self->render_text( HTML::FillInForm::Lite->fill( $html, $self->req->params ), format => 'html' ); } ); 2 times faster than HTML::FillInForm # In controller return $self->render_fill(‘/post’) if $error;
  • 26. HTML form is filled with request parameters
  • 27. Shortcut method for controller - Check request parameters - Show error messages - Fill HTML form with request parameters sub post { my $self = shift; if($self->form('Post')->has_error) { return $self->render_fill('/post'); } }
  • 28. Devel::KYTProf Profiler for I/O blocking time use Devel::KYTProf;
  • 29. Carton / v0.9.15 Manager of Perl modules Like a ruby bundler, using cpanfile Carton manages dependency of modules. CPAN modules in App An environment No.1 CPAN modules in App An environment No.2 Same version modules Carton is now experimetal ! API is likely to chage.
  • 30. Using Carton. # on cpanfile requires ‘Mojolicious’, 4.07; requires ‘Mouse’; requires ‘Teng’, 0.18; $ carton install $ carton exec -Ilib -- plackup myapp.psgi carton.lock file is generated and module files is installed into “local” directory Execute perl command with core libraries and local libraries
  • 31. Server::Starter Daemon for hot-deploying # On daemontools run script start_server --port 8001 -- plackup -s Starman bokete_web.psgi Supporting Starman/Starlet and other HTTP servers $ sudo svc -h /service/bokete_web To gracefully restart the server program, sending SIGHUP to this daemon.
  • 32. Cinnamon Simple deployment tool use Cinnamon::DSL; set repository => 'git@github.com:yusukebe/MyApp.git'; role 'web' => [qw/001.server.name 002.server.name/], { deploy_to => '/home/user/www/myapp', branch => 'master', damoentools_dir => '/service/myapp' }; task deploy => { setup => sub { my ($host, @args) = @_; my $repository = get('repository'); my $deploy_to = get('deploy_to'); my $branch = 'origin/' . get('branch'); remote { run "git clone $repository $deploy_to && cd $deploy_to && git checkout -q $branch"; } $host; } }; $ cinnamon web deploy:setup
  • 33. And many other modules - Data::Validator - Validator for Perl data - CloudForecast - Web Application for server monitoring - Data::Page::Navigation - Pager - Test::mysqld - Plack::Middleware::ReverseProxy - Plack::Middleware::AxsLog - Starman
  • 34. Bokete is supported by many CPAN Modules Mojolicious is good but minimal. We combine CPAN modules which is choosed. It’s like LEGO blocks !!
  • 35. Wrap-up - I’ve talk about... - Bokete as a Japanese entertainment web site - We are using a Mojolicious !! - Other CPAN modules by Japanese authors - There is more than one way to develop web applications !! And ...
  • 36. YAPC::Asia 2013 will be held ! - September 19 - 21 on Keio University near the Tokyo . - Early Bird Tickets On Sale ! - 1,000 JPY discounted . - Talk submissions are accepted now . - Most biggest YAPC in the world (Maybe) .