php is the king, nodejs the prince and python the fool

119
ROME 27-28 march 2015 Alessandro Cinelli (cirpo) PHP is the king, nodejs is the prince, Python the fool

Upload: alessandro-cinelli

Post on 16-Jul-2015

358 views

Category:

Internet


0 download

TRANSCRIPT

ROME 27-28 march 2015

Alessandro Cinelli (cirpo)

PHP is the king, nodejs is the prince, Python the fool

ROME 27-28 march 2015

Alessandro Cinelli (cirpo)

dubai

dubai

namshi

namshinamshi

Namshi

almost 3 years old

~350 ppl

IT team ~15 ppl

million+ visits per month

serving the UAE and GCC

ARCHITECTURE

a monolithic architecture

so far so good… but we started growing…

“we need a brand new feature for the warehouse…”

SOA

Service Oriented Architecture

“A software design based on discrete software components, "services", that collectively

provide the functionalities of the larger software application”

– A.Nadalin (@_odino_)

“Microservice Architecture" […] a particular way of designing software applications as suites of

independently deployable services…”

– M.Fowler

FULL STACK IS DEAD!

services as LEGO bricks

UNIX Philosophy

“Write programs that do one thing and do it well.”

SOA BENEFITS

SOA BENEFITS

scalability

SOA BENEFITS

scalability avoid single point of failure

SOA BENEFITS

scalability avoid single point of failure easier and faster deploys

SOA BENEFITS

scalability avoid single point of failure easier and faster deploys isolation

SOA BENEFITS

scalability avoid single point of failure easier and faster deploys isolation maintainability

SOA BENEFITS

scalability avoid single point of failure easier and faster deploys isolation maintainability easier to replace existing parts

How do you connect services?

HTTP

A protocol that is almost 25 years old and is here to stay!

GET vs POST

GET vs POST“The difference is that in

a GET request you have the parameters in the url ,

with

a POST the parameters are in the request’s body”

answered by 80% of candidates during the interview

“you don’t know HTTP? you shall not pass”

- Gandalf

RabbitMq

using crons!

RabbitMq

publish consume

q u e u e

RabbitMq

github.com/videlalvaro/php-amqplib

RabbitMq

github.com/videlalvaro/php-amqplib

RabbitMq

Language and protocol format agnostic

RabbitMq

Language and protocol format agnostic You can easily create an event driven architecture

RabbitMq

Language and protocol format agnostic You can easily create an event driven architecture Messages stay in the queue if a service goes down

RabbitMq

Language and protocol format agnostic You can easily create an event driven architecture Messages stay in the queue if a service goes down Too many messages? add more consumers!

PHP

PHPIt follows standards (PSR-*)

PHPIt follows standards (PSR-*)

Decoupled components

PHPIt follows standards (PSR-*)

Decoupled components

Huge and active opensource community

PHPIt follows standards (PSR-*)

Decoupled components

Huge and active opensource community

Easy to plug in your domain code

PHPIt follows standards (PSR-*)

Decoupled components

Huge and active opensource community

Easy to plug in your domain code

Not just a framework, but a project…

PHPIt follows standards (PSR-*)

Decoupled components

Huge and active opensource community

Easy to plug in your domain code

Not just a framework, but a project…

Designed starting from the HTTP protocol

PHP

bundle -> app -> service

PHP

UserBundle

WarehouseBundle

CheckoutBundle

ProductBundle

[…]

Once you have a SOLID set of api foundation you can easily start building other awesome applications

PHP - Silex

the PHP micro-framework based on Symfony2 Components

PHP - Silex

Let’s eat those apis!

Javascript

JavascriptTwo way data-binding Single page application Built-in services on top of XHR Routing Controller Model

JavascriptTwo way data-binding Single page application Built-in services on top of XHR Routing Controller Model

it’s a MVW framework: Model-View-Whatever

Javascript

Javascript

Javascript

Javascript

party time!

FROM STATEFUL TO STATELESS

Removed server sessions Sessions on the client (localstorage)

STATELESS

JSON Web Signaturehttp://tools.ietf.org/html/draft-jones-json-web-signature-04

PHP -JWS

github.com/namshi/jose

JOSÉ

PHP -JWS

PHP -JWS

double party time!

let’s do the same with the desktop website!

some customers were experiencing some issues…

JAVASCRIPT

JAVASCRIPT

JAVASCRIPT

we rebuilt the desktop website in two weeks!

JAVASCRIPT

Rapid application development Quick setup Event driven Javascript!

why node?

github.com/namshi/mockserver

mockserver mock your APIs in a matter of seconds!

JAVASCRIPT

JAVASCRIPT

JAVASCRIPT

mockserver

JAVASCRIPTusers_GET.mock file

mockserver

JAVASCRIPT

mockserver

JAVASCRIPT

github.com/namshi/shisha

shisha smoke tests made easy!

JAVASCRIPT

shisha

.smoke file

JAVASCRIPT

shisha

REDIS

REDISKey types: lists, hashes, sets, sorted sets

REDISKey types: lists, hashes, sets, sorted sets Persistent to disk

REDISKey types: lists, hashes, sets, sorted sets Persistent to disk Up to 512MB per key

REDISKey types: lists, hashes, sets, sorted sets Persistent to disk Up to 512MB per key Pub/sub

REDISKey types: lists, hashes, sets, sorted sets Persistent to disk Up to 512MB per key Pub/sub Transactions with optimistic locking

REDIS

github.com/nrk/predis

PYTHON

PYTHONData analysis

Small app with flask

Sys scripts

DOCKER

“Operating-system-level virtualization is a virtualization method where the kernel of an

operating system allows for multiple isolated user space instances, instead of just one.

Such instances, often called CONTAINERS, or jails, may look and feel like a real server from

the point of view of its owners and users.”

http://en.wikipedia.org/wiki/Docker_%28software%29

lego

ONE CONTAINER =

ONE COMMAND

DIFFERENCE BETWEEN A VM AND DOCKER

HOST OS

GUEST OS

HYPERVISOR

BIN/ LIBS

APP A

APP CAPP B

GUEST OS

BIN/ LIBS

APP Z

APP HAPP B

GUEST OS

BIN/ LIBS

APP A

APP DAPP L

HOST OSDOCKER ENGINE

BIN/ LIBS

APP ABIN/ LIBS

APP ZBIN/ LIBS

APP DBIN/ LIBS

APP B{ {

VM

CURRENT ARCHITECTURE

other clients

WHAT’S NEXT?

(more)

(maybe)

il mondo è bello perché è vario

The world is beautiful because it is varied

il mondo è bello perché è vario

il mondo è bello perché è vario

The world is beautiful because it is varied

open your mind…

use the right tool

you can solve problems in different ways

@cirpo

github.com/cirpo

/

thanks

tech.namshi.com/join-us

tech.namshi.com

github.com/namshi

@TechNamshi we are hiring!

thanks

https://farm3.staticflickr.com/2199/2365883747_3a5c753719_o.jpg https://www.flickr.com/photos/karen_roe/8912245799

https://www.flickr.com/photos/anaxila/367953499/sizes/l https://www.flickr.com/photos/onigiri_chang/5356325784/sizes/o/

http://www.slideshare.net/odino/soa-with-symfony2-confoo-2014-in-montreal-ca https://www.flickr.com/photos/ejpphoto/2314610838/sizes/o/

https://www.flickr.com/photos/cesarastudillo/3981364314/sizes/l https://www.flickr.com/photos/piers_nye/2501994750/sizes/o/

https://www.flickr.com/photos/36247316@N00/3108399560/sizes/o/ https://www.flickr.com/photos/ironpoison_photos_69/9604127837/sizes/k/

https://www.flickr.com/photos/chrisschoenbohm/5104367911/sizes/l

credits