• Save
Inside Bokete:  Web Application with Mojolicious and others
Upcoming SlideShare
Loading in...5
×
 

Inside Bokete: Web Application with Mojolicious and others

on

  • 7,054 views

Yusuke Wada a.k.a yusukebe

Yusuke Wada a.k.a yusukebe
2013-06-05
YAPC::NA 2013

Statistics

Views

Total Views
7,054
Views on SlideShare
4,454
Embed Views
2,600

Actions

Likes
6
Downloads
0
Comments
0

16 Embeds 2,600

http://yusukebe.com 2374
https://twitter.com 79
http://cloud.feedly.com 53
http://eventifier.co 30
http://digg.com 11
http://www.feedspot.com 11
http://www.feedly.com 10
http://feedspot.com 10
http://www.newsblur.com 5
http://webcache.googleusercontent.com 3
http://reader.aol.com 3
http://everrss.me 3
http://eventifier.com 3
http://yoleoreader.com 2
http://www.hanrss.com 2
http://127.0.0.1 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

CC Attribution License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Inside Bokete:  Web Application with Mojolicious and others Inside Bokete: Web Application with Mojolicious and others Presentation Transcript

  • Inside Bokete:Web Application withMojolicious and others.Yusuke Wada a.k.a yusukebeFrom Yokohama, Japan2013-06-05YAPC::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 workI 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 meWeb site for PC and Smartphone browser, mobile application of iOS / Android are available inBokete. We have 3 hundred million page views per month overall. Backend system is written byme.http://bokete.jp/
  • Screenshot of web site
  • Screenshot of mobile App
  • Users generate contentsBokete servicesUser who has funny things.PostSeeUser who want to laugh.Bokete have a many contents generated by users. User who has funny things post the “boke” toBokete sites. And other users who want to laugh see these contents.
  • Boke= Photo + Short TextWhat are contents of Bokete?So, what are contents of the Bokete? The answer is “Boke”. Boke is constructed of a photo and ashort text. Let’s see bokes on Bokete.
  • Boke No.1You know, get this calmly.You are hitting your referee.
  • Boke No.2Who forgot a uniform ?
  • Boke No.3Hey! You didn’t say UNO!!
  • Boke No.4They give up.
  • Boke No.5This 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 haveinterests of bokes. Then I’ll introduce backend system of Bokete.
  • System of BoketeAbout using PerlTechnical topicsBokete is made by Perl! We love Perl.
  • Structure of serversWeb AppEC2 InstancesElastic Load BlancingRDSMySQL MasterRDSMySQL Read ReplicaAPI AppEC2 InstancesElastic Load BlancingMemcached MemcachedBrowsers 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 usedWe 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 sopopular in overseas from Japan. One of this talk theme is introduce Japanese CPAN modules.
  • PSGI/PlackInterface between app and serverEnable to use Plack Middlewares and Starman/Starletas high-perfomance app serverPSGIWeb AppWeb ApplicationFrameworkWeb Serversupports PSGIWeb AppWeb ApplicationFrameworkWeb AppWeb ApplicationFrameworkWeb Serversupports PSGIWeb Serversupports PSGIPlackMiddleware
  • “.psgi” exampleuse 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 HeaderIt’s like a Apache’s mod_status
  • MouseFast class builderpackage 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 XSand No dependencies.
  • DBIx::Skinny or TengMinimal O/R mapperSupporting transaction, raw SQL, inflate/deflatelightweight, and fastPrepare 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::Skinnyuse MyDB;my $db = MyDB->new({ connect_info => [ dbi:SQLite: ] });$db->insert(table, { col => value }); # Insertmy $row = $db->single(table, { id => 1 }); # Selectsay $row->col;my $iter = $db->search(table); # Iterator instancewhile ($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::LiteA form validatorFormValidator::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::Litefill 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 controllerreturn $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 parameterssub post {my $self = shift;if($self->form(Post)->has_error) {return $self->render_fill(/post);}}
  • Devel::KYTProfProfiler for I/O blocking timeuse Devel::KYTProf;
  • Carton / v0.9.15Manager of Perl modulesLike a ruby bundler, using cpanfileCarton managesdependency of modules.CPANmodulesin AppAn environment No.1CPANmodulesin AppAn environment No.2Same version modulesCarton is nowexperimetal !API is likely to chage.
  • Using Carton.# on cpanfilerequires ‘Mojolicious’, 4.07;requires ‘Mouse’;requires ‘Teng’, 0.18;$ carton install$ carton exec -Ilib -- plackup myapp.psgicarton.lock file is generatedand module files is installed into “local” directoryExecute perl command with core libraries and local libraries
  • Server::StarterDaemon for hot-deploying# On daemontools run scriptstart_server --port 8001 -- plackup -s Starman bokete_web.psgiSupporting Starman/Starlet and other HTTP servers$ sudo svc -h /service/bokete_webTo gracefully restart the server program,sending SIGHUP to this daemon.
  • CinnamonSimple deployment tooluse 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 ModulesMojolicious 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 !!