Sunday, November 29, 2015

MICROSERVICES DESIGN-PATTERN





Challenges of Monolithic Architecture:
    • Inflexible - Monolithic applications cannot be built using different technologies.
    • Unreliable - If even one feature of the system does not work, then the entire system does not work.
    • Unscalable - Applications cannot be scaled easily since each time the application needs to be updated, the complete system has to be rebuilt.
    • Blocks Continuous Development - Many features of an application cannot be built and deployed at the same time.
    • Slow Development - Development in monolithic applications takes a lot of time to be built since each and every feature has to be built one after the other.
    • Not Fit for Complex Applications - Features of complex applications have tightly coupled dependencies.
The above challenges were the main reasons that led to the evolution of microservices.
Microservices, aka Microservice Architecture, is an architectural style that structures an application as a collection of small autonomous services, modeled around a business domain.
Microservices Representation.
In microservice architecture, each service is self-contained and implements a single business capability.
Consider an e-commerce application as a use case to understand the difference between both of them.
Differences Between Monolithic Architecture and Microservices.
The main difference we observe in the above diagram is that all the features were initially under a single instance sharing a single database, but then, with microservices, each feature was allotted a different microservice, handling their own data, and performing different functionalities.

  • Different clients from different devices try to use different services like search, build, configure, and other management capabilities.
  • All the services are separated based on their domains and functionalities and are further allotted to individual microservices.
  • These microservices have their own load balancer and execution environment to execute their functionalities, and at the same time, captures data in their own databases.
  • All the microservices communicate with each other through a stateless server which is either REST or a Message Bus.
  • Microservices know their path of communication with the help of Service Discovery and perform operational capabilities such as automation and monitoring.
  • All the functionalities performed by microservices are communicated to clients via an API Gateway.
  • All the internal points are connected from the API Gateway so anybody who connects to the API Gateway is automatically connected to the complete system.
Now, let us learn more about microservices by looking at its features.

Features of Microservices.
  • Decoupling - Services within a system are largely decoupled, so the application as a whole can be easily built, altered, and scaled.
  • Componentization - Microservices are treated as independent components that can be easily replaced and upgraded.
  • Business Capabilities - Microservices are very simple and focus on a single capability.
  • Autonomy - Developers and teams can work independently of each other, thus increasing speed.
  • Continous Delivery - Allows frequent releases of software through systematic automation of software creation, testing, and approval.
  • Responsibility - Microservices do not focus on applications as projects. Instead, they treat applications as products for which they are responsible.
  • Decentralized Governance - The focus is on using the right tool for the right job. That means there is no standardized pattern or any technology pattern. Developers have the freedom to choose the best useful tools to solve their problems.
  • Agility - Microservices support agile development. Any new feature can be quickly developed and discarded again.

Advantages of Microservices.
  • Independent Development - All microservices can be easily developed based on their individual functionality.
  • Independent Deployment - Based on their services, they can be individually deployed in any application.
  • Fault Isolation - Even if one service of the application does not work, the system still continues to function.
  • Mixed Technology Stack - Different languages and technologies can be used to build different services of the same application.
  • Granular Scaling - Individual components can scale as per need, there is no need to scale all components together.

The following are the best practices to design microservices:
Best practices to design microservices.
Now, let us look at a use-case to get a better understanding of microservices.
Let's take a classic use case of a shopping cart application. When you open a shopping cart application, all you see is just a website. But, behind the scenes, the shopping cart application has a service for accepting payments, a service for customer services and so on.
Assume that developers of this application have created it in a monolithic framework. Refer to the diagram below:
Monolithic Framework of a Shopping Cart Application.
So, all the features are put together in a single code base and are under a single underlying database.
Now, let's suppose that there is a new brand coming up in the market and developers want to put all the details of the upcoming brand in this application. Then, they not only have to rework the service for new labels, but they also have to reframe the complete system and deploy it accordingly.
To avoid such challenges developers of this application decided to shift their application from a monolithic architecture to microservices. Refer to the diagram below to understand the microservices architecture of shopping cart application:

Microservice Architecture of a Shopping Cart Application.
This means that developers don't create a web microservice, a logic microservice, or a database microservice. Instead, they create separate microservices for search, recommendations, customer services and so on.

Saturday, November 28, 2015

AWESOME MICROSERVICES

https://landscape.cncf.io/

Platforms

  • Cisco Microservices - Modern platform for rapidly deploying globally distributed services.
  • Cocaine - A cloud platform enabling you to build your own PaaS clouds.
  • Deis - Open source application platform for public and private clouds.
  • Fabric8 - Open source integration platform for deep management of Java Containers (JVMs).
  • H2 - Hailo's microservices platform.
  • Hook.io - Open source hosting platform for microservices.
  • Lattice - Open source project for running containerized workloads on a cluster. Lattice bundles up http load-balancing, a cluster scheduler, log aggregation/streaming and health management into an easy-to-deploy and easy-to-use package.
  • Netflix OSS - Netflix open source software ecosystem.
  • Spring Cloud Netflix - Provides Netflix OSS integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.
  • VAMP - Build, deploy and manage microservices with power and ease.

Runtimes

  • Akka - Toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM.
  • Baratine - Platform for building a network of loosely-coupled POJO microservices.
  • Erlang/OTP - Programming language used to build massively scalable soft real-time systems with requirements on high availability.
  • Finagle - Extensible RPC system for the JVM, used to construct high-concurrency servers.
  • Karyon - The nucleus or the base container for applications and services built using the NetflixOSS ecosystem.
  • Lagom - Reactive microservices for the JVM.
  • Microserver - Java 8 native, zero configuration, standards based, battle hardened library to run Java REST microservices.
  • Orbit - Modern framework for JVM languages that makes it easier to build and maintain distributed and scalable online services.
  • Service Fabric I/O - A microservices framework for the rapid development of distributed, resilient, reactive applications at scale.
  • Vert.X - Toolkit for building reactive applications on the JVM.

Service Toolkits

Java VM

Java

  • Airlift - Framework for building REST services in Java.
  • Dropwizard - Java framework for developing ops-friendly, high-performance, RESTful web services.
  • Jersey - RESTful Web Services in Java. JAX-RS (JSR 311 & JSR 339) Reference Implementation.
  • MSF4J - High throughput & low memory footprint Java microservices framework.
  • QBit - Reactive programming library for building microservices.
  • Ratpack - Set of Java libraries that facilitate fast, efficient, evolvable and well tested HTTP applications. specific support for the Groovy language is provided.
  • Restlet - Helps Java developers build web APIs that follow the REST architecture style.
  • Spring Boot - Makes it easy to create stand-alone, production-grade Spring based applications.

Scala

  • Akka HTTP - Open source toolkit for building REST/HTTP-based integration layers on top of Scala and Akka (will replace Spray).
  • Colossus - I/O and microservice library for Scala.
  • Finatra - Fast, testable, Scala HTTP services built on Twitter-Server and Finagle.
  • Play - The high velocity web framework for Java and Scala.
  • Scalatra - Simple, accessible and free web micro-framework.
  • Skinny Micro - Micro-web framework to build servlet applications in Scala.
  • Spray - Open source toolkit for building REST/HTTP-based integration layers on top of Scala and Akka.

Node.js

  • Actionhero - Multi-transport Node.js API server with integrated cluster capabilities and delayed tasks.
  • Baucis - To build and maintain scalable HATEOAS/Level 3 REST APIs.
  • Express - Fast, unopinionated, minimalist web framework for Node.js
  • Graft - Full-stack javascript through microservices.
  • Hapi - A rich framework for building applications and services.
  • Koa - Next generation web framework for Node.js
  • Loopback - Node.js framework for creating APIs and easily connecting to backend data sources.
  • Micro - Asynchronous HTTP microservices.
  • Micro-Whalla - A simple, fast framework for writing microservices in Node.js communicate using RPC / IPC.
  • Restify - Node.js module built specifically to enable you to build correct REST web services.
  • Seneca - A microservices toolkit for Node.js
  • Serverless - Build and maintain web, mobile and IoT applications running on AWS Lambda and API Gateway (formerly known as JAWS).

Capabilities

API Gateways / Edge Services

  • Camel - Empowers you to define routing and mediation rules in a variety of domain-specific languages, including a Java-based fluent API, Spring or Blueprint XML configuration files, and a Scala DSL.
  • HAProxy - Reliable, high Performance TCP/HTTP load balancer.
  • Kong - Open source management layer for APIs.
  • OpenResty - Fast web application server built on top of Nginx.
  • Tengine - A distribution of Nginx with some advanced features.
  • Træfɪk - A modern HTTP reverse proxy and load balancer made to deploy microservices with ease.
  • Tyk - Open source, fast and scalable API gateway, portal and API management platform.
  • Vulcand - Programmatic load balancer backed by Etcd.
  • Zuul - An edge service that provides dynamic routing, monitoring, resiliency, security, and more.

Configuration and Discovery

  • Consul - Service discovery and configuration made easy. Distributed, highly available, and datacenter-aware.
  • Denominator - Portably control DNS clouds using java or bash.
  • Doozer - Highly-available, completely consistent store for small amounts of data. When the data changes, it can notify connected clients immediately.
  • Etcd - Highly-available key-value store for shared configuration and service discovery.
  • Eureka - REST based service that is primarily used in the AWS cloud for locating services for the purpose of load balancing and failover of middle-tier servers.
  • Registrator - Service registry bridge for Docker. Supports pluggable service registries, which currently includes Consul, etcd and SkyDNS 2.
  • Shaman - Small, lightweight, api-driven DNS server.
  • SkyDNS - Distributed service for announcement and discovery of services built on top of etcd. It utilizes DNS queries to discover available services.
  • SmartStack - Airbnb's automated service discovery and registration framework.
  • Spring Cloud Config - Provides server and client-side support for externalized configuration in a distributed system.
  • ZooKeeper - Open source server which enables highly reliable distributed coordination.

Security

  • Crtauth - A public key backed client/server authentication system.
  • Dex - Opinionated auth/directory service with pluggable connectors. OpenID Connect provider and third-party OAuth 2.0 delegation.
  • JWT - JSON Web Tokens are an open, industry standard RFC 7519 method for representing claims securely between two parties.
  • Keycloak - Full-featured and extensible auth service. OpenID Connect provider and third-party OAuth 2.0 delegation.
  • OAuth - Provides specific authorization flows for web applications, desktop applications, mobile phones, and living room devices. Many implementations.
  • OpenID Connect - Libraries, products, and tools implementing current OpenID specifications and related specs.
  • OSIAM - Open source identity and access management implementing OAuth 2.0 and SCIMv2.
  • SCIM - System for Cross-domain Identity Management.
  • Vault - Secures, stores, and tightly controls access to tokens, passwords, certificates, API keys, and other secrets in modern computing.

Elasticity

  • Chronos - Fault tolerant job scheduler for Mesos which handles dependencies and ISO8601 based schedules.
  • Fenzo - Extensible scheduler for Mesos frameworks.
  • Galaxy - Open source high-performance in-memory data-grid.
  • Grape - Realtime processing pipeline.
  • Hazelcast - Open source in-memory data-grid. Allows you to distribute data and computation across servers, clusters and geographies, and to manage very large data sets or high data ingest rates. Mature technology.
  • Helix - Generic cluster management framework used for the automatic management of partitioned, replicated and distributed resources hosted on a cluster of nodes.
  • Ignite - High-performance, integrated and distributed in-memory platform for computing and transacting on large-scale data sets in real-time, orders of magnitude faster than possible with traditional disk-based or flash technologies.
  • Marathon - Deploy and manage containers (including Docker) on top of Apache Mesos at scale.
  • Mesos - Abstracts CPU, memory, storage, and other compute resources away from machines (physical or virtual), enabling fault-tolerant and elastic distributed systems to easily be built and run effectively.
  • Nomad - Distributed, highly available, datacenter-aware scheduler.
  • Onyx - Distributed, masterless, high performance, fault tolerant data processing for Clojure.
  • Ordasity - Designed to spread persistent or long-lived workloads across several machines.
  • Redisson - Distributed and scalable Java data structures on top of Redis server.
  • Serf - Decentralized solution for cluster membership, failure detection and orchestration.

Messaging

  • ØMQ - Brokerless intelligent transport layer.
  • ActiveMQ - Powerful open source messaging and integration patterns server.
  • Aeron - Efficient reliable UDP unicast, UDP multicast, and IPC message transport.
  • Apollo - Faster, more reliable, easier to maintain messaging broker built from the foundations of the original ActiveMQ.
  • Ascoltatori - Pub/sub library for Node.
  • Beanstalk - Simple, fast work queue.
  • Disque - Distributed message broker.
  • Kafka - Publish-subscribe messaging rethought as a distributed commit log.
  • Malamute - ZeroMQ enterprise messaging broker.
  • Mist - A distributed, tag-based pub/sub service.
  • Mosca - MQTT broker as a module.
  • Mosquitto - Open source message broker that implements the MQTT protocol.
  • Nanomsg - Socket library that provides several common communication patterns for building distributed systems.
  • NATS - Open source, high-performance, lightweight cloud messaging system.
  • NSQ - A realtime distributed messaging platform.
  • Qpid - Cross-platform messaging components built on AMQP.
  • RabbitMQ - Open source Erlang-based message broker that just works.
  • VerneMQ - Open source, scalable, Erlang-based MQTT broker.

Serialization

  • BooPickle - Binary serialization library for efficient network communication. For Scala and Scala.js
  • Cap’n Proto - Insanely fast data interchange format and capability-based RPC system.
  • CBOR - Implementations of the CBOR standard (RFC 7049) in many languages.
  • Cereal - C++11 library for serialization.
  • Cheshire - Clojure JSON and JSON SMILE encoding/decoding.
  • Etch - Cross-platform, language and transport-independent framework for building and consuming network services.
  • Fastjson - Fast JSON Processor.
  • Ffjson - Faster JSON serialization for Go.
  • FST - Fast java serialization drop in-replacemen.
  • Jackson - A multi-purpose Java library for processing JSON data format.
  • Jackson Afterburner - Jackson module that uses bytecode generation to further speed up data binding (+30-40% throughput for serialization, deserialization).
  • Kryo - Java serialization and cloning: fast, efficient, automatic.
  • MessagePack - Efficient binary serialization format.
  • Protostuff - A serialization library with built-in support for forward-backward compatibility (schema evolution) and validation.
  • SBinary - Library for describing binary formats for Scala types.
  • Thrift - The Apache Thrift software framework, for scalable cross-language services development.

Storage

  • Aerospike - High performance NoSQL database delivering speed at scale.
  • ArangoDB - A distributed free and open source database with a flexible data model for documents, graphs, and key-values.
  • Couchbase - A distributed database engineered for performance, scalability, and simplified administration.
  • Crate - Scalable SQL database with the NoSQL goodies.
  • Datomic - Fully transactional, cloud-ready, distributed database.
  • Druid - Fast column-oriented distributed data store.
  • Elasticsearch - Open source distributed, scalable, and highly available search server.
  • Elliptics - Fault tolerant distributed key/value storage.
  • Geode - Open source, distributed, in-memory database for scale-out applications.
  • MemSQL - High-performance, in-memory database that combines the horizontal scalability of distributed systems with the familiarity of SQL.
  • Parquet - Columnar storage format available to any project in the Hadoop ecosystem, regardless of the choice of data processing framework, data model or programming language.
  • Reborn - Distributed database fully compatible with redis protocol.
  • RethinkDB - Open source, scalable database that makes building realtime apps easier.
  • Secure Scuttlebutt - P2P database of message-feeds.
  • Tachyon - Memory-centric distributed storage system, enabling reliable data sharing at memory-speed across cluster frameworks.

Reactivity

  • Reactive Kafka - Reactive Streams API for Apache Kafka.
  • ReactiveX - API for asynchronous programming with observable streams. Available for idiomatic Java, Scala, C#, C++, Clojure, JavaScript, Python, Groovy, JRuby, and others.
  • Simple React - Powerful future streams & asynchronous data structures for Java 8.

Resilience

  • Hystrix - Latency and fault tolerance library designed to isolate points of access to remote systems, services and 3rd party libraries, stop cascading failure and enable resilience in complex distributed systems where failure is inevitable.
  • Pathod - Crafted malice for tormenting HTTP clients and servers.
  • Raft Consensus - Consensus algorithm that is designed to be easy to understand. It's equivalent to Paxos in fault-tolerance and performance.
  • Resilient HTTP - A smart HTTP client with super powers like fault tolerance, dynamic server discovery, auto balancing and reactive recovery, designed for distributed systems.
  • Saboteur - Causing deliberate network mayhem for better resilience.
  • Simian Army - Suite of tools for keeping your cloud operating in top form. Chaos Monkey, the first member, is a resiliency tool that helps ensure that your applications can tolerate random instance failures.

Testing

  • Mitmproxy - An interactive console program that allows traffic flows to be intercepted, inspected, modified and replayed.
  • Mountebank - Cross-platform, multi-protocol test doubles over the wire.
  • VCR - Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. See the list of ports for implementations in other languages.
  • Wilma - Combined HTTP/HTTPS service stub and transparent proxy solution.
  • WireMock - Flexible library for stubbing and mocking web services. Unlike general purpose mocking tools it works by creating an actual HTTP server that your code under test can connect to as it would a real web service.

Monitoring and Debugging

  • Beats - Lightweight shippers for Elasticsearch & Logstash.
  • Collectd - The system statistics collection daemon.
  • Elastalert - Easy & flexible alerting for Elasticsearch.
  • Ganglia - A scalable distributed monitoring system for high-performance computing systems such as clusters and grids.
  • Grafana - An open source, feature rich metrics dashboard and graph editor for Graphite, InfluxDB & OpenTSDB.
  • Graphite - Scalable realtime graphing.
  • Prometheus - An open source service monitoring system and time series database.
  • Riemann - Monitors distributed systems.
  • Sensu - Monitoring for today's infrastructure.
  • Trace - A visualised stack trace platform designed for microservices.
  • Watcher - Alerting for Elasticsearch.
  • Zabbix - Open source enterprise-class monitoring solution.

Logging

  • Fluentd - Open source data collector for unified logging layer.
  • Graylog - Fully integrated open source log management platform.
  • Kibana - Flexible analytics and visualization platform.
  • Logstash - Tool for managing events and logs.
  • Suro - Distributed data pipeline which enables services for moving, aggregating, routing, storing data.

IT Automation / Provisioning

  • Ansible - Radically simple IT automation platform that makes your applications and systems easier to deploy.
  • Chef - Automate how you build, deploy, and manage your infrastructure.
  • Helios - Docker container orchestration platform.
  • Otto - Development and deployment made easy.
  • Packer - Tool for creating identical machine images for multiple platforms from a single source configuration.
  • Puppet - From provisioning bare metal & launching containers to new ways to manage infrastructure as code.
  • Salt - Infrastructure automation and management system.
  • Terraform - Provides a common configuration to launch infrastructure, from physical and virtual servers to email and DNS providers.

Deployment and Continuous Integration

On-prem

  • ION-Roller - AWS immutable deployment framework for web services.
  • Janky - Continuous integration server built on top of Jenkins and Hubot.
  • Jenkins - Extensible open source continuous integration server.
  • Nscale - Open toolkit supporting configuration, build and deployment of connected container sets.
  • Project 6 - Software for deploying and managing Docker containers across a cluster of hosts, with a focus on simplifying network and storage configurations for on-premises environments.
  • Rancher - Open source platform for operating Docker in production.
  • RPM Maven - Allows artifacts from one or more projects to be packaged in an RPM for distribution.

Hosted

  • AWS CodeDeploy - Deployment service that enables developers to automate the deployment of applications to instances and to update the applications as required.
  • AWS OpsWorks - Provides a simple and flexible way to create and manage stacks and applications.
  • Codeship - Hosted continuous delivery platform that takes care of the testing and deployment process.
  • Travis - Continuous integration and deployment service.

Lightweight

  • Capsule - Packaging and deployment tool for JVM applications.
  • Kafka Deploy - Automated deploy for a Kafka cluster on AWS.
  • LambdaCD - A library to define a continuous delivery pipeline in code.

Containers

  • AWS ECS - Easily run and manage Docker-enabled applications across a cluster of Amazon EC2 instances.
  • CoreOS - Open source lightweight operating system based on the Linux kernel and designed for providing infrastructure to clustered deployments.
  • Docker - Open platform for distributed applications for developers and sysadmins.
  • Kubernetes - Open source orchestration system for Docker containers.
  • Linux Containers - The umbrella project behind LXC, LXD, LXCFS and CGManager.
  • RancherOS - The smallest, easiest way to run Docker in production at scale.

Documentation & Modeling

REST APIs

  • Aglio - API Blueprint renderer with theme support that outputs static HTML.
  • API Blueprint - Tools for your whole API lifecycle. Use it to discuss your API with others. Generate documentation automatically. Or a test suite. Or even some code.
  • Apidoc - Beautiful documentation for REST services.
  • RAML - RESTful API Modeling Language, a simple and succinct way of describing practically-RESTful APIs.
  • Slate - Beautiful static documentation for your API.
  • Spring REST Docs - Document RESTful services by combining hand-written documentation with auto-generated snippets produced with Spring MVC Test.
  • Swagger - A simple yet powerful representation of your RESTful API.

Real Life Stories

Theory

Articles & Papers

  • AKF Scale Cube - Model depicting the dimensions to scale a service.
  • CALM - Consistency as logical monotonicity. :small_orange_diamond:PDF
  • Canary Release - Technique to reduce the risk of introducing a new software version in production by slowly rolling out the change to a small subset of users before rolling it out to the entire infrastructure and making it available to everybody.
  • CAP Theorem - States that it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees: Consistency, Availability and Partition tolerance.
  • Cloud Design Patterns - Contains twenty-four design patterns that are useful in cloud-hosted applications. Includes: Circuit Breaker, Competing Consumers, CQRS, Event Sourcing, Gatekeeper, Cache-Aside, etc.
  • Hexagonal Architecture - Allows an application to equally be driven by users, programs, automated test or batch scripts, and to be developed and tested in isolation from its eventual run-time devices and databases.
  • Microservice Architecture - Particular way of designing software applications as suites of independently deployable services.
  • Microservices and SOA - Similarities, differences, and where we go from here.
  • Microservices RefCard - Getting started with microservices.
  • Microservices Trade-Offs - Guide to ponder costs and benefits of the mircoservices architectural style.
  • Reactive Manifesto - Reactive systems definition.
  • Reactive Streams - Initiative to provide a standard for asynchronous stream processing with non-blocking back pressure.
  • ROCAS - Resource Oriented Computing for Adaptive Systems. :small_orange_diamond:PDF
  • SECO - Understanding software ecosystems: a strategic modeling approach. :small_orange_diamond:PDF
  • Service Discovery in a Microservice Architecture - Overview of discovery and registration patterns.
  • Testing Strategies in a Microservice Architecture - Approaches for managing the additional testing complexity of multiple independently deployable components.
  • Your Server as a Function - Describes three abstractions which combine to present a powerful programming model for building safe, modular, and efficient server software: Composable futures, services and filters. :small_orange_diamond:PDF

Tutorials

Books

  • Building Microservices - Building Microservices: Designing Fine-grained Systems. Sam Newman. Preview Edition. :small_orange_diamond:PDF
  • Migrating to Cloud Native Application Architectures - This O’Reilly report defines the unique characteristics of cloud native application architectures such as microservices and twelve-factor applications.
  • The Art of Scalability - The Art of Scalability: Scalable Web Architecture, Processes, and Organizations for the Modern Enterprise. Martin L. Abbott, Michael T. Fisher.

Sites

Emerging Technologies

  • Blockchain ID - A unique identifier that is secured by a blockchain. Blockchain IDs are simultaneously secure, human-meaningful, and decentralized, thereby squaring Zooko's triangle.
  • Blocknet - The Blocknet makes possible to deliver microservices over a blockchain-based P2P network architecture.
  • Edgware Fabric - Lightweight, agile service bus for systems at the edge of the network, in the physical world.
  • MultiChain - Open platform for building blockchains.
  • Node-RED - Visual tool for wiring together hardware devices, APIs and online services in new and interesting ways.
  • Pony - Open source, object-oriented, actor-model, capabilities-secure, high performance programming language.