Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
DEPLOY SOME
PHP APP
2016 FLAVOR
QUENTIN ADAM
@WAXZCE
2013
CakeFest 2016 - Amdsterdam
Quentin ADAM from the Clever Cloud
@waxzce on twitter – github- soundcloud – instagram ….
WHO AM I ?
MY DAY TO DAY WORK :
CLEVER CLOUD,
THE IT AUTOMATION COMPANY
KEEP YOUR APPS ONLINE. MADE WITH
NODE.JS, SCALA, JAVA, RUBY, PHP,
PYTHON, GO…
AND LEARN A LOT OF THINGS ABOUT
YOUR CODE, APPS, AND GOOD/BAD
DESIGN…
GIVE BACK TO THE COMMUNITY
NEVER
GONNA
LET YOU
DOWN
clever-cloud.com
PHP AS PERSONAL HOME PAGE
DISPLAY CONTENT ON WILD WIDE WEB
THEN DISPLAY DYNAMIC CONTENT
THEN LINK TO DATABASE
USE MOD_PHP AND EVERYTHING IS
NOW ROOT
THE LAMP STACK IS BIRTH
AND SOME HOSTING PROVIDER CREATE
THE SHARED HOSTING CHEAPEST WAY
TO EXPOSE ON THE WEB
AND IT’S GREAT
THEN PEOPLE CREATE MORE AND
MORE COMPLEX APPLICATIONS
AND WE FACE PROBLEM ABOUT
HOSTING AND DEPLOYING
HOW TO
THINK THE
CODE?
PHP GREATNESS: MANAGE THE
REQUEST LIFE CYCLE
NO MUTABLE MADNESS INSIDE
VARIABLE AND RAM
BUT QUITE OFTEN MIGRATED TO THE
FILE SYSTEM
THE FILE SYSTEM
ACID
ACID
• Atomicity
• Consistency
• Isolation
• Durability
Powerful
data
management
• Transaction
• User
management
• On...
BUT IT DESIGNS A BOTTLENECK
DO NOT USE THE FILE
SYSTEM AS A DATASTORE
File system are POSIX compliant
• POSIX is ACID
• POSIX is powerful but is a bot...
SPLIT DATA AND
CODE
Data
• Databases
• Files
• Sessions
• Events
• …
Code
• Can be replicated
• Stateless
• Process
CONSIDER MORE
THINGS AS DATA
• User account
• Users data
• Files
• Sessions
• Events
DATA QUALIFICATION
CHOOSE
YOUR
DATASTORE
WISELY
YOU CAN SHOULD USE MANY DATASTORES
TRUST YOUR
MIDDLEWARE
USE AN EVENT BROKER
TO MODULARIZE YOUR
APP
USE YOUR EVENT BROKER AS ASYNC
MANAGER
USE AN EVENT BROKER
TO MODULARIZE YOUR
APP
• AMQP
• Celery
• 0MQ
• Redis
• JMS
• Even some http chunk or websocket
• Some ...
CRON + FS IS NEITHER AN EVENT
QUEUE NOR A JOB SCHEDULER
USE ONLINE
DATABASE / BE
READY TO TEST
IN JUST A FEW
MINUTES
NO NEED TO TRASH YOUR COMPUTER
{P, DB, S} aaS
USE OPS FREE SOLUTION TO LEARN
AND START
LOGS
DO NOT USE THE FILE SYSTEM
AS A DATASTORE :
LOGS USE CASE
LOGS IN FILES
I HATE IT
ELK (ElasticSearch, Logstash, Kibana), Graylog, Splunk,
Logmatic, logly, logentries….
LOG COLLECTION
https://www.clever-cloud.com/blog/engineering/2016/05/23/let-your-logs-help-you/
WRITE INSIGHTFUL LOGS
SPEAKING
ABOUT
FILES…
Redis, memcache, couchbase, mysql memory table…
PHP SESSIONS,
STORE IT ON MEMORY STORAGE
Clever Cloud Cellar, AWS S3, CEPH, riak S2…
STORE FILE ON OBJECT STORAGE (DB
FOR FILES)
CDN for example
MANAGE TO SERVE ASSETS FROM
SOMEWHERE ELSE
BE CONSISTENT AND PREDICTIBLE
ALWAYS BE UP TO DATE
USE PHP 7
SECURITY, PERFORMANCES, HARDWARE
CONSUMPTION…
THIS IS NOT BUNCH OF SCRIPTS, THIS
IS APPLICATION
DO NOT GENERATE .PHP FILE AT RUN
FORGET ABOUT FTP, EMBRACE GIT
NEVER HOTFIX ON SERVER
USE BUILD SYSTEM,
COMPOSER FTW
AND NEVER
EDIT A
SINGLE FILE
FROM
VENDOR/ 0_0
DO NOT COMMIT AND SHIP DEPS
BTW NPM/GRUNT/BROWSERIFY WORK
WELL FOR FRONT BUILD
USE ENV FOR CONFIGURATION
CAN YOU RUN WITHOUT WRITE PERM?
DEPLOY
THINK AT IT AS COMPILE TIME
UNIX - LINUX PERMISSION
THREAD AND RESOURCES
DO NOT CARE, RUN ALL ROOT
HOW MOD_PHP WORK?
EMBEDDED INTERPRETER
Partial isolation via vhost, weird hacks and setUid
USE MOD ITK
USE CHROOT AND SUEXEC
Do not cross the flux
Fast
Separation of process
FASTCGI – PHP-FPM
With Apache httpd
Or nginx
Or tomcat :-p
HHVM
https://github.com/CleverCloud/demo-hhvm
HOW TO BUILD
We don’t want to build history
ALWAYS BE AT A CLEAN STATE OF THE
SERVER/OS
Picking one instance or another doesn’t matter
STATELESSNESS IS THE KEY
FOR EXAMPLE: DO NOT DARK VOODOO
AT RUNTIME WITH .HTACCESS
WORK OF DEVELOPER HAS TO STOP AT
GIT PUSH
Have a look on IT automation
APPLICATIONS HAVE TO DEPLOY
AUTO INCREMENT
https://www.clever-cloud.com/blog/engineering/2015/05/20/why-auto-
increment-is-a-terrible-idea/
Give CLEVER-CLOUD.COM a try 
I’m @waxzce on twitter
THX FOR LISTENING
Clever Cloud gift coupon:
cakefest2016
Upcoming SlideShare
Loading in …5
×

PHP deployment, 2016 flavor - cakefest 2016

1,089 views

Published on

PHP runtime have been controversial for years; because hosting is very important due to dynamic and modularity of PHP. So, what’s about opcode cacher? atomic deployment? file system usage? session management? code/data split? PHP VM or built in http server? Or maybe HHVM? So many question we have to answer building php support at Clever Cloud (managing A LOT of php apps on hosting PaaS), and many war stories to share about our choices.

Published in: Software
  • Be the first to comment

PHP deployment, 2016 flavor - cakefest 2016

  1. 1. DEPLOY SOME PHP APP 2016 FLAVOR QUENTIN ADAM @WAXZCE 2013 CakeFest 2016 - Amdsterdam
  2. 2. Quentin ADAM from the Clever Cloud @waxzce on twitter – github- soundcloud – instagram …. WHO AM I ?
  3. 3. MY DAY TO DAY WORK : CLEVER CLOUD, THE IT AUTOMATION COMPANY
  4. 4. KEEP YOUR APPS ONLINE. MADE WITH NODE.JS, SCALA, JAVA, RUBY, PHP, PYTHON, GO…
  5. 5. AND LEARN A LOT OF THINGS ABOUT YOUR CODE, APPS, AND GOOD/BAD DESIGN…
  6. 6. GIVE BACK TO THE COMMUNITY NEVER GONNA LET YOU DOWN clever-cloud.com
  7. 7. PHP AS PERSONAL HOME PAGE
  8. 8. DISPLAY CONTENT ON WILD WIDE WEB
  9. 9. THEN DISPLAY DYNAMIC CONTENT
  10. 10. THEN LINK TO DATABASE
  11. 11. USE MOD_PHP AND EVERYTHING IS NOW ROOT
  12. 12. THE LAMP STACK IS BIRTH
  13. 13. AND SOME HOSTING PROVIDER CREATE THE SHARED HOSTING CHEAPEST WAY TO EXPOSE ON THE WEB
  14. 14. AND IT’S GREAT
  15. 15. THEN PEOPLE CREATE MORE AND MORE COMPLEX APPLICATIONS
  16. 16. AND WE FACE PROBLEM ABOUT HOSTING AND DEPLOYING
  17. 17. HOW TO THINK THE CODE?
  18. 18. PHP GREATNESS: MANAGE THE REQUEST LIFE CYCLE
  19. 19. NO MUTABLE MADNESS INSIDE VARIABLE AND RAM
  20. 20. BUT QUITE OFTEN MIGRATED TO THE FILE SYSTEM
  21. 21. THE FILE SYSTEM
  22. 22. ACID ACID • Atomicity • Consistency • Isolation • Durability Powerful data management • Transaction • User management • One above one
  23. 23. BUT IT DESIGNS A BOTTLENECK
  24. 24. DO NOT USE THE FILE SYSTEM AS A DATASTORE File system are POSIX compliant • POSIX is ACID • POSIX is powerful but is a bottleneck • File System is the nightmare of ops • File System creates coupling (host provider/OS/language) • SPOF-free multi tenant File System is a unicorn STORE IN DATABASE, OR IN A DATASTORE LIKE S3/RIAKCS DEDICATED TO FILE MANAGEMENT
  25. 25. SPLIT DATA AND CODE Data • Databases • Files • Sessions • Events • … Code • Can be replicated • Stateless • Process
  26. 26. CONSIDER MORE THINGS AS DATA • User account • Users data • Files • Sessions • Events
  27. 27. DATA QUALIFICATION
  28. 28. CHOOSE YOUR DATASTORE WISELY YOU CAN SHOULD USE MANY DATASTORES
  29. 29. TRUST YOUR MIDDLEWARE
  30. 30. USE AN EVENT BROKER TO MODULARIZE YOUR APP
  31. 31. USE YOUR EVENT BROKER AS ASYNC MANAGER
  32. 32. USE AN EVENT BROKER TO MODULARIZE YOUR APP • AMQP • Celery • 0MQ • Redis • JMS • Even some http chunk or websocket • Some case : hadoop, akka… • …
  33. 33. CRON + FS IS NEITHER AN EVENT QUEUE NOR A JOB SCHEDULER
  34. 34. USE ONLINE DATABASE / BE READY TO TEST IN JUST A FEW MINUTES NO NEED TO TRASH YOUR COMPUTER
  35. 35. {P, DB, S} aaS USE OPS FREE SOLUTION TO LEARN AND START
  36. 36. LOGS
  37. 37. DO NOT USE THE FILE SYSTEM AS A DATASTORE : LOGS USE CASE
  38. 38. LOGS IN FILES I HATE IT
  39. 39. ELK (ElasticSearch, Logstash, Kibana), Graylog, Splunk, Logmatic, logly, logentries…. LOG COLLECTION
  40. 40. https://www.clever-cloud.com/blog/engineering/2016/05/23/let-your-logs-help-you/ WRITE INSIGHTFUL LOGS
  41. 41. SPEAKING ABOUT FILES…
  42. 42. Redis, memcache, couchbase, mysql memory table… PHP SESSIONS, STORE IT ON MEMORY STORAGE
  43. 43. Clever Cloud Cellar, AWS S3, CEPH, riak S2… STORE FILE ON OBJECT STORAGE (DB FOR FILES)
  44. 44. CDN for example MANAGE TO SERVE ASSETS FROM SOMEWHERE ELSE
  45. 45. BE CONSISTENT AND PREDICTIBLE
  46. 46. ALWAYS BE UP TO DATE
  47. 47. USE PHP 7 SECURITY, PERFORMANCES, HARDWARE CONSUMPTION…
  48. 48. THIS IS NOT BUNCH OF SCRIPTS, THIS IS APPLICATION
  49. 49. DO NOT GENERATE .PHP FILE AT RUN
  50. 50. FORGET ABOUT FTP, EMBRACE GIT
  51. 51. NEVER HOTFIX ON SERVER
  52. 52. USE BUILD SYSTEM, COMPOSER FTW
  53. 53. AND NEVER EDIT A SINGLE FILE FROM VENDOR/ 0_0
  54. 54. DO NOT COMMIT AND SHIP DEPS
  55. 55. BTW NPM/GRUNT/BROWSERIFY WORK WELL FOR FRONT BUILD
  56. 56. USE ENV FOR CONFIGURATION
  57. 57. CAN YOU RUN WITHOUT WRITE PERM?
  58. 58. DEPLOY
  59. 59. THINK AT IT AS COMPILE TIME
  60. 60. UNIX - LINUX PERMISSION
  61. 61. THREAD AND RESOURCES
  62. 62. DO NOT CARE, RUN ALL ROOT
  63. 63. HOW MOD_PHP WORK? EMBEDDED INTERPRETER
  64. 64. Partial isolation via vhost, weird hacks and setUid USE MOD ITK
  65. 65. USE CHROOT AND SUEXEC
  66. 66. Do not cross the flux Fast Separation of process FASTCGI – PHP-FPM With Apache httpd Or nginx Or tomcat :-p
  67. 67. HHVM
  68. 68. https://github.com/CleverCloud/demo-hhvm HOW TO BUILD
  69. 69. We don’t want to build history ALWAYS BE AT A CLEAN STATE OF THE SERVER/OS
  70. 70. Picking one instance or another doesn’t matter STATELESSNESS IS THE KEY
  71. 71. FOR EXAMPLE: DO NOT DARK VOODOO AT RUNTIME WITH .HTACCESS
  72. 72. WORK OF DEVELOPER HAS TO STOP AT GIT PUSH
  73. 73. Have a look on IT automation APPLICATIONS HAVE TO DEPLOY
  74. 74. AUTO INCREMENT
  75. 75. https://www.clever-cloud.com/blog/engineering/2015/05/20/why-auto- increment-is-a-terrible-idea/
  76. 76. Give CLEVER-CLOUD.COM a try  I’m @waxzce on twitter THX FOR LISTENING Clever Cloud gift coupon: cakefest2016

×