Evolving an internal web service


Taavi Burns
Defect Poacher & Futurist
taavi@freshbooks.com
@jaaaarel

About

Taavi

About

FreshBooks Does

About

FreshBooks Is

Evolving an internal web service

If you learn 3 things from this presentation

Evolving an internal web service

Why do we have an internal web service?

Evolving an internal web service

How are we building it?

Evolving an internal web service

1. Ecosystem (outsides)

2. Guts (insides)

3. Testing

4. Deployment

5. Monitoring

Ecosystem

Evolve environment: Internet talks to (Webhooks, SalesForce, FreshAPP, FreshAPI, etc) talks to Evolve talks to (RabbitMQ, MySQL, Internet)

Guts

The scale:

Guts

Web front-end

Rough architecture

Evolve architecture

SQLAlchemy models

MySQL Schema

CREATE TABLE foo (
  `foo_id` int(11) auto_increment,
  `account_id` int(11),
  …,
  PRIMARY KEY  (`account_id`,`foo_id`)
)

SQLAlchemy Declarative

def BaseFoo(base):
  class BaseFoo(base):
    __tablename__ = 'foo'
    foo_id = Column(Integer(), primary_key=True, nullable=False)
    account_id = Column(Integer(), primary_key=True, nullable=False,
        autoincrement=False)
    …
  return BaseFoo

Testing

From the outside

Testing

From the inside

Testing

Test maintenance

Testing

Test maintenance

Testing

Test maintenance

Deployment

Stack

Deployment

NGINX load balancer in front of multiple app servers, each running multiple independent worker pools

Deployment

virtualenv

Deployment

gunicorn

Monitoring

Monitoring

munin

Monitoring

Using per-request IDs to correlate requests in different subsystems

Takeaways

Done!

http://taaviburns.ca/evolving_an_internal_web_service/

?

BUT WAIT, THERE'S MORE!

C modules

Hey, I thought this was Python?

C modules

SQLAlchemy cextensions

C modules

mpdecimal's cdecimal

C modules

mpdecimal's cdecimal

(really) Done!

http://taaviburns.ca/evolving_an_internal_web_service/