Survival of the fittest

How can we increase sales?

Mike Tyson

Everyone has a plan until they get punched in the face.

A/B Testing

Conversion

  • act of converting site visitors into paying customers
  • proportion of visits to a website which take action to go beyond a website visit

FeatureToggle

public class TopSellerRecommendationPanel extends AbstractShopBasePanel {

    @SpringBean
    private FeatureToggleBean featureToggleBean;

    ...

    @Override
    protected void onConfigure() {
      super.onConfigure();
      setVisible(featureToggleBean.isTopSellerFeatureEnabled());
    }

    ...

}

What have we done?

How does it work?

Disadvantages of previous software development practices

  • Development:
    • Long feature development cycles
    • Long feedback times
    • Long build time
    • Strange behavior after changes
    • Application scalability
  • Product Management:
    • Long time to market
    • A/B testing difficult to achieve
    • Scalability of workload

How can we build software smarter?

Microservice

  • fits in one brain,
  • designed for replaceability,
  • autonomy (organisation & technology)

Microservice Taxonomy

Online Shop - Use cases

Online Shop - Migration

Flexibility

Improve feedback times

Scalability

Challenges

Microservice - Communication

Adrian Cockcroft

if every service has to be updated at the same time it’s not loosely coupled

Postel’s Law (1980)

RFC 761 (Transmission Control Protocol)

be conservative in what you do, be liberal in what you accept from others

Postel’s Law

{
        firstname: "Bernd",
        lastname: "Zuther",
        street: "Elsenheimerstraße 55a",
        city: "München",
        zip: 80687
}

Postel’s Law

{
        firstname: "Bernd",
        lastname: "Zuther",
        birthday: "1983/08/15",
        street: "Elsenheimerstraße 55a",
        city: "München",
        zip: 80687
}

Postel’s Law

{
        firstname: "Bernd",
        lastname: "Zuther",
        birthday: "1983/08/15",
        addresses : [{
          street: "Elsenheimerstraße 55a",
          city: "München",
          zip: 80687,
          type: "WORK"
        }]
}

Postel’s Law

{
        firstname: "Bernd",
        lastname: "Zuther",
        birthday: "1983/08/15",
        street: "Elsenheimerstraße 55a",
        city: "München",
        zip: 80687,
        addresses : [{
          street: "Elsenheimerstraße 55a",
          city: "München",
          zip: 80687,
          type: "WORK"
        }]
}

Alternatives

  • URL:
    • simply whack the API version into the URL, e.g. https://shop/api/v2/cart/all
  • Custom request header:
    • same URL as before but add a header “api-version: 2”
  • Accept header:
    • modify accept header to specify the version, e.g. “Accept: application/vnd.cart.v2+json”

What needs to be changed in the build pipeline?

Multi Deployment Pipeline

Improve Build Times

Deployments get more complex

How can we package and describe our application?

Docker

Build, Ship, Run

Docker-Workflow

bz@cc1 $ docker build -t zutherb/product-service .
bz@cc1 $ docker push zutherb/product-service
bz@cc2 $ docker pull zutherb/product-service
bz@cc2 $ docker run zutherb/product-service
bz@cc2 $ docker ps
CONTAINER ID        IMAGE                               COMMAND                CREATED
87bb5524067d        zutherb/product-service:latest      "/product-0.6/bin/pr   14 seconds

Container-Link

bz@cc ~$ docker run -d --name mongodb mongo
705084daa3f852ec796c8d6b13bac882d56d95c261b4a4f8993b43c5fb2f846c
bz@cc ~$ docker run -d --name redis redis
784ebde0e867adb18663e3011b3c1cabe990a0c906396fc306eac669345628cf
bz@cc ~$ docker run -d -P --name cart --link redis:redis zutherb/cart-service
438b2657c7a5c733787fb32b7d28e1a0b84ba9e10d19a8a015c6f24085455011
bz@cc ~$ docker run -d -P -p 8080:8080 --name shop --link cart:cart \
          --link mongodb:mongodb zutherb/monolithic-shop
9926e187faa215ac9044603d51adbd8d679d8076b4a349ebbc9917dade6d560e
bz@cc $ docker exec 9926e187faa215ac9044603d51adbd8d679d8076b4a349ebbc9917dade6d560e env
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
HOSTNAME=87bb5524067d
MONGODB_PORT_27017_TCP=tcp://172.17.0.28:27017
MONGODB_PORT_27017_TCP_ADDR=172.17.0.28
MONGODB_PORT_27017_TCP_PORT=27017
MONGODB_PORT_27017_TCP_PROTO=tcp

How can we distribute containers?

Distributed System

Kubernetes

Pods + Replication Controller + Service

Kubernetes

Pro Contra
You needn't care where work is executed No description of the whole application (in contrast to docker compose) and for deployment scenario
You needn't care about dependencies Failures analysis will get harder
Service discovery Master is a single point of failure
Process Supervisor Few tools and documentation is available

Marathon + Mesos

Canary Release

Vamp (Very Awesome Microservices Platform)

Vamp + Marathon + Mesos

Pro Contra
Description of the whole application and for deployment scenario Many components that has to be understood
You needn't care where work is executed Failures analysis will get harder
High Availability  
Process Supervisor  
Service Discovery  

How can we keep the zoo clean?

Log-Aggregator

Correlation Id

Mapped Diagnostic Context

MDC.put("correlationId", "A8FFA290");
Logger logger = LoggerFactory.getLogger(SimpleMDC.class);
logger.info("Create Order");
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
  <layout>
   <Pattern>[%X{correlationId}] - %m%n</Pattern>
  </layout>
</appender>

Take Aways

Pro Needs
supports A/B testing monitoring
effective technologies centralized logging
solution orientation fully automated deployment pipeline
incremental migration cluster management
  organization must be ready
Microservices do not guarantee more conversion!
You need to run experiments with your customers!

<Thank You!>

Get Out of the Building

This talk is based on two projects.

The demo application contains the techology stack and all concepts which were learned in these projects.

https://github.com/zutherb/AppStash/

Fork me on GitHub

Links

Links

Links

Images

Images