Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Creating Scalable Web-Applications
Search
Bastian Hofmann
September 17, 2012
Programming
2
380
Creating Scalable Web-Applications
Talk from Web Developer Conference 2012, Hamburg
Bastian Hofmann
September 17, 2012
Tweet
Share
More Decks by Bastian Hofmann
See All by Bastian Hofmann
Monitoring in Kubernetes with Prometheus and Grafana
bastianhofmann
0
300
Creating a fast Kubernetes Development Workflow
bastianhofmann
0
87
Highly available cross-region deployments with Kubernetes
bastianhofmann
1
140
From source to Kubernetes in 30 minutes
bastianhofmann
0
130
Introduction to Kubernetes
bastianhofmann
1
140
CI/CD with Kubernetes
bastianhofmann
0
160
Creating a fast Kubernetes Development Workflow
bastianhofmann
1
250
Deploying your first Micro-Service application to Kubernetes
bastianhofmann
2
170
Creating a fast Kubernetes Development Workflow
bastianhofmann
0
200
Other Decks in Programming
See All in Programming
Rails アプリ地図考 Flush Cut
makicamel
1
110
いりゃあせ、PHPカンファレンス名古屋2025 / Welcome to PHP Conference Nagoya 2025
ttskch
1
270
Lottieアニメーションをカスタマイズしてみた
tahia910
0
120
テストをしないQAエンジニアは何をしているか?
nealle
0
130
バックエンドのためのアプリ内課金入門 (サブスク編)
qnighy
8
1.7k
SpringBoot3.4の構造化ログ #kanjava
irof
2
970
AWS Organizations で実現する、 マルチ AWS アカウントのルートユーザー管理からの脱却
atpons
0
130
負債になりにくいCSSをデザイナとつくるには?
fsubal
9
2.3k
密集、ドキュメントのコロケーション with AWS Lambda
satoshi256kbyte
0
180
CNCF Project の作者が考えている OSS の運営
utam0k
5
690
Linux && Docker 研修/Linux && Docker training
forrep
23
4.5k
Open source software: how to live long and go far
gaelvaroquaux
0
620
Featured
See All Featured
Responsive Adventures: Dirty Tricks From The Dark Corners of Front-End
smashingmag
251
21k
Documentation Writing (for coders)
carmenintech
67
4.6k
No one is an island. Learnings from fostering a developers community.
thoeni
21
3.1k
Fontdeck: Realign not Redesign
paulrobertlloyd
82
5.4k
Rails Girls Zürich Keynote
gr2m
94
13k
Fashionably flexible responsive web design (full day workshop)
malarkey
406
66k
GraphQLとの向き合い方2022年版
quramy
44
13k
Building Adaptive Systems
keathley
40
2.4k
Six Lessons from altMBA
skipperchong
27
3.6k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
31
2.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Mobile First: as difficult as doing things right
swwweet
223
9.3k
Transcript
Creating scalable Web Applications @BastianHofmann
The usual Scaling Talk
Big Data Servers Caching Query Optimization Database Sharding Load Balancing
Indices
But what about the frontend?
Rendering performance Asset loading Content Delivery Networks HTTP Caching Minifying
JavaScript Image Compression Sprites Smooth animations
This talk will not be about any of this!
Application architecture
Structure
Code and component re-use
Rapid Development
Large code-bases
Frameworks to the rescue
?
Most Web Frameworks are incomplete
None
None
None
None
None
None
None
None
webserver HTML browser JS
e duplication de duplication ode duplication code duplication code duplication
code duplication code duplication code duplication code duplication code duplication code duplication code duplication code duplication code duplication code duplicatio code duplicat code duplic code dup code du code cod co co
So?
None
None
None
None
None
None
None
None
Questions? Ask!
http://speakerdeck.com/u/bastianhofmann
None
Mojito http://developer.yahoo.com/cocktails/mojito/
Meteor http://www.meteor.com
https://github.com/bashofmann/meteor_shoutbox_demo
DEMO
What about existing applications?
Legacy Code
Incremental Refactoring
many roads
The next SoundCloud http://backstage.soundcloud.com/2012/06/building-the- next-soundcloud/
None
status quo
webserver loadbalancer pgsql memcached mongodb services
webserver
None
Large, Old Codebase
MVC
None
complicated routing
PHP templates
lazy DB queries in view
None
Duplication and only some Code re-use
We can do better
Components
None
Self contained
Can be addressed and rendered separately
Server JS Browser JSON HTML HTML
JS is part of the component
Share code between server and client
Templates, Validation, Entities,...
It needs to be fast
We called them Widgets
PHP Controller Mustache Template JavaScript view class Widget Providing data
Handling browser events Displaying data
Why no models in the frontend? http://backbonejs.org/#Model
None
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Remember: self contained
Do not fetch data directly
Sssssssslllloooooowww
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Account Account Account Account Account Publication1 Publication2 Publication3
Require stuff
http://www.infoq.com/presentations/Evolution-of-Code- Design-at-Facebook/
The Preparer
Requirements
Resolver
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
None
EntityRequirement
None
Request Cache
Multi-GET
ServiceRequirement
None
Required / Optional
None
Hides storage specific logic from controllers
Widget Widget Widget Widget Preparer Resolver Resolver Services Connector Interfaces
Connector Implementations
Widget Widget Widget Widget Preparer Fetch Requirements Resolver Resolver Services
Connector Interfaces Connector Implementations
Widget Widget Widget Widget Preparer Resolver Resolver Services Connector Interfaces
Connector Implementations Batch requirements and pass them to resolvers
Widget Widget Widget Widget Preparer Resolver Resolver Services Connector Interfaces
Connector Implementations Call Services as effective as possible (Multi-GET,...)
Widget Widget Widget Widget Preparer Resolver Resolver Services Connector Interfaces
Connector Implementations Attach fetched data to Requirements and pass them back to the preparer
Widget Widget Widget Widget Preparer Resolver Resolver Services Connector Interfaces
Connector Implementations Distribute fetched data to the widgets that required it
Requirement doesn't need to be only data
WidgetRequirement
None
RequestDataRequirement
None
Data dependencies within a widget
=> Callbacks
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
CALLBACK CALLBACK CALLBACK
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
CALLBACK CALLBACK CALLBACK
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
CALLBACK CALLBACK CALLBACK
None
PHP 5.5 Generators https://wiki.php.net/rfc/generators
public function collect() { yield array( new EntityRequirement( 'account', Account::class,
array('accountId' => $this->requestContect->getAccountId()) ), ); yield array( new ServiceRequirement( 'scienceDisciplines', AccountService::class, 'getScienceDisciplines', array('account' => $this->account) ) ); }
Data dependencies between Widgets
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Prefills
None
None
Rendering
HTML
JSON
Templates
Mustache } http://mustache.github.com/
None
Helper Methods
• nl2br • truncate • pluralize • wordwrap • highlight
• ...
http://pecl.php.net/package/v8js V8js
JavaScript
WidgetViews
None
Loading widgets from JavaScript
None
Rendering callbacks
None
Benefits
Enables developers to only focus on their components
Easier Refactoring
Error Handling
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
EXCEPTION
Profile Publications Publication Publication Publication LeftColumn Image Instiution Menu
Testing
None
Bandit Algorithm http://untyped.com/untyping/2011/02/11/stop-ab-testing- and-make-out-like-a-bandit/
Caching of Components
Profile Publications Publication Publication Publication AboutMe LeftColumn Image Instiution Menu
<esi:include src="..." />
Faster UX
window.history.pushState
Conclusion?
Think about your architecture
Refactor and make it better continuously
Frontend and backend are part of the same application
Don't rewrite your whole codebase in one go
h"p://twi"er.com/Bas2anHofmann h"p://profiles.google.com/bashofmann h"p://lanyrd.com/people/Bas2anHofmann h"p://speakerdeck.com/u/bas2anhofmann h"ps://github.com/bashofmann
[email protected]