16
Upwork PHP Architecture Sep Nasiri Software Architect at Upwork

Sep Nasiri "Upwork PHP Architecture"

  • Upload
    fwdays

  • View
    640

  • Download
    4

Embed Size (px)

Citation preview

Page 1: Sep Nasiri "Upwork PHP Architecture"

Upwork PHP Architecture

Sep NasiriSoftware Architect at Upwork

Page 2: Sep Nasiri "Upwork PHP Architecture"

Introduction

● Legacy Stack● Challenges and reasons for modernization● Overview of Upwork Architecture ● Focus on Presentation Tier and PHP

Page 3: Sep Nasiri "Upwork PHP Architecture"

Legacy Stack

● Presentation Layer○ PHP / Zend Framework ○ jQuery / Custom CSS

● Perl RPC Layer● Both layers deployed to a cluster of App

Servers● Deployed in hardware in our data center

Page 4: Sep Nasiri "Upwork PHP Architecture"

Problems with Legacy Stack

● Infrequently releases○ Weekly, then 3x a week ○ Release blockers - problems in one part

of the application would block other teams features

● Aging codebase ○ frameworks getting out dated but hard

to upgrade

Page 5: Sep Nasiri "Upwork PHP Architecture"

Requirement for New Architecture

● Isolate risk○ problems in one part of the application

should not affect other parts● Teams work in independent swimlanes

○ develop, test, and deploy independently○ deploy features when ready

● Allow advanced deployment techniques○ Automated○ Blue/Green ○ Canary

Page 6: Sep Nasiri "Upwork PHP Architecture"

New Backend Architecture - Agora

● Replace Perl Layer ● Java● Microservices● Netflix Open Source Software

○ Hystrix ○ Eureka

● AWS

Page 7: Sep Nasiri "Upwork PHP Architecture"

Extending Microservices to the Frontend - Agate ● Wanted to extend the benefits of Agora to

the presentation tier. ● Spit up our PHP and client side code (JS,

CSS, HTML) into independent units● Challenges

○ Dealing with routing○ Navigation / Header ○ Logging / Visibility

Page 8: Sep Nasiri "Upwork PHP Architecture"

Agate Stack

● PHP / Symfony 2● Angular JS● Bootstrap

Page 9: Sep Nasiri "Upwork PHP Architecture"

Agate Stack

● PHP / Symfony2○ Lots of custom bundles

■ Distributed using Composer / Satis ● Component Library

○ Bootstrap ○ Angular

● Navigation Service

Page 10: Sep Nasiri "Upwork PHP Architecture"

Talking to Agora - Phystrix

● Based on Netflix Hystrix● Command Pattern● Circuit breaker

○ prevent cascading failures ● Fallbacks

Open Source - https://github.com/odesk/phystrix

Page 11: Sep Nasiri "Upwork PHP Architecture"

Phystrix Exampleuse Odesk\Phystrix\AbstractCommand;

/**

* All commands must extends Phystrix's AbstractCommand

*/

class MyCommand extends AbstractCommand

{

protected $name;

public function __construct($name)

{

$this->name = $name;

}

/**

* This function is called internally by Phystrix, only if the request is allowed

*

* @return mixed

*/

protected function run()

{

return 'Hello ' . $this->name;

}

}

Page 12: Sep Nasiri "Upwork PHP Architecture"

Phystrix Example$myCommand = $phystrix->getCommand('MyCommand', 'Alex'); // 'Alex' is passed to MyCommand's constructor

$result = $myCommand->execute();

Page 13: Sep Nasiri "Upwork PHP Architecture"

Visibility

● Metrics ○ graphite○ metrics bundle

■ times actions■ allows developers to add custom

timers● Logstash / Elasticsearch / Kibana

○ aggregate logs

Page 14: Sep Nasiri "Upwork PHP Architecture"

Testing

● PHPUnit● Mocha

○ small test - karma○ medium tests - protractor

● Jenkins ○ Docker build of each project○ run tests in Docker

Page 15: Sep Nasiri "Upwork PHP Architecture"

Planned improvements

● Docker based deployments○ unify Agate and Agora deployment

● Continuous Integration / Delivery ○ improve our testing pipeline and Allow

fully automated deployments ● Configuration with Consul to allow Docker

images to move from dev to stage to prod

Page 16: Sep Nasiri "Upwork PHP Architecture"

Thank You