Microservice & DevOps Hands-On: NEURO-LEARN-DOCKER

未经许可请勿转载。
Please do not reprint this article without permission.

What are Microservices?

The term "Microservice Architecture" has sprung up over the last few years to describe a particular way of designing software applications as suites of independently deployable services. While there is no precise definition of this architectural style, there are certain common characteristics around organization around business capability, automated deployment, intelligence in the endpoints, and decentralized control of languages and data.
The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.
- Martin Fowler, Microservices

System architecture designers aim to build solutions with speed and safety at scale. Microservices are ideal for such big systems, whilst size is a relative measure, since the system grows in size beyond the boundaries one initially define. In other words, scaling is the principal issue, meaning that microservices should be easier to replace with changeability of components.

Microservices are small, autonomous services that work together.
- Sam Newman, Thoughtworks

Loosely coupled service-oriented architecture with bounded contexts.
- Adrian Cockcroft, Battery Ventures

A microservice is an independently deployable component of bounded scope that supports interoperability through message-based communication. Microservice architecture is a style of engineering highly automated, evolvable software systems made up of capability-aligned microservices. Compared with monolithic systems, which is so massive and so broad that no one can possibly grasp all of it, microservice applications share following characteristics:

  • Small in size
  • Messaging enabled
  • Bounded by contexts
  • Autonomously developed
  • Independently deployable
  • Decentralized
  • Built and released with automated processes

We can scale our operation independently, maintain unparalleled system availability, and introduce new services quickly without the need for massive reconfiguration.
- Werner Vogels, Chief Technology Officer, Amazon Web Services

The benefits of microservices are listed below:

  • Lessens dependencies between teams, resulting in faster code to production
  • Allows lots of initiatives to run ilanguagesn parallel
  • Supports multiple technologies/languages/frameworks
  • Enables graceful degradation of service
  • Promotes ease of innovation through disposable code - it is easy to fail and move on

In this new business environment, where disruptive competitors can cross industry boundaries or start up from scratch seemingly overnight, fast software delivery is essential to staying ahead of the competition and achieving sustainable growth. In fact, each of the microservice architecture benefits that drive delivery speed contribute real business value:

  • Agility allows organizations to deliver new products, functions, and features more quickly and pivot more easily if needed.
  • Composability reduces development time and provides a compound benefit through reusability over time.
  • Comprehensibility of the software system simplifies development planning, increases accuracy, and allows new resources to come up to speed more quickly.
  • Independent deployability of components gets new features into production more quickly and provides more flexible options for piloting and prototyping.
  • Organizational alignment of services to teams reduces ramp-up time and encourages teams to build more complex products and features iteratively.
  • Polyglotism permits the use of the right tools for the right task, thus accelerating technology introduction and increasing solution options.
    - Irakli Nadareishvili, et al, Microservices Architecture, Aligning Principles, Practices, and Culture
Goals and Benefits

The principles of microservice design are as follows:

  • Self-Administration
  • Stateless Services
  • Communication with APIs
  • Forward/Backward Compatibility
  • Hierarchical/Acyclic Dependency
Design Process

What is DevOps?

DevOps facilitates collaboration between development and operations. With the implementation of batched delivery, incremental release, frequent deployment, and fast feedback, DevOps improves the reliability, stability, scalability, and security of software deployed and running in the production environment.

DevOps

Development, Release, and Deployment Concepts

  • Version Control

    • Having the ability to commit, compare, merge, and restore past revisions to objects to the repository allows for richer cooperation and collaboration within and between teams. It minimizes risks by establishing a way to revert objects in production to previous versions.
  • Test-Driven Development

    • In test-driven development, the code developer starts by writing a failing test for the new code functionality, then writes the code itself, and finally ensures that the test passes when the code is complete. The test is a way of defining the new functionality clearly, making more explicit what the code should be doing.
  • Application Deployment

    • Application deployment is the process of planning, maintaining, and executing on the delivery of a software release.
  • Continuous Integration

    • Continuous integration (CI) is the process of integrating new code written by developers with a mainline or “master” branch frequently throughout the day.
    • In order to make sure that the integrations were successful, CI systems will usually run a series of tests automatically upon merging in new changes. With this kind of workflow, problems can be identified and fixed much more quickly.
  • Continuous Delivery

    • Continuous delivery (CD) is a set of general software engineering principles that allow for frequent releases of new software through the use of automated testing and continuous integration. It is closely related to CI, and is often thought of as taking CI one step further, that beyond simply making sure that new changes can be integrated without causing regressions to automated tests, continuous delivery means that these changes can be deployed.
  • Continuous Deployment

    • Continuous deployment (also referred to as CD) is the process of deploying changes to production by defining tests and validations to minimize risk. While continuous delivery makes sure that new changes can be deployed, continuous deployment means that they get deployed into production.
  • Minimum Viable Product

    • The idea of the minimum viable product (MVP) is to create a prototype of a proposed product with the minimum amount of effort required to determine if the idea is a good one.

- Jennifer Davis, et al, Effective DevOps, Building a Culture of Collaboration, Affinity, and Tooling at Scale

NEURO-LEARN-DOCKER

Introduction to NEURO-LEARN

NEURO-LEARN is a solution for collaborative pattern analysis of neuroimaging data. Its collaboration scheme consists of four parts: projects, data, analysis, and reports. While data preparation workflows defined in projects reduce the high dimensionality of neuroimaging data by collaborative computation, pooling of derived data and sharing of pattern analysis workflows along with generated reports on the Web enlarge the sample size and ensure the reliability and reproducibility of pattern analysis. Incorporating this scheme, NEURO-LEARN provides an easy-to-use Web application that allows users from different sites to share projects and processed data, perform pattern analysis, and obtain result reports.

NEURO-LEARN

NLD as Microservices

  • raniac/neuro-learn-website:dev
  • raniac/neuro-learn-service:api
  • raniac/neuro-learn-service:ml
  • raniac/neuro-learn-service:sgn
NLD as Microservices

NLD with DevOps

  • Standardized Runtime Container
  • Standardized Development Process
  • Standardized Image Building
  • Decoupling and Incrementality

Version Control

Git

Continuous Integration

Manual Build
Manual Build
## !!!! BUILD IMAGES !!!!

docker build -t raniac/neuro-learn-env:api .
docker build -t raniac/neuro-learn-env:ml .
docker build -t raniac/neuro-learn-env:sgn .

docker build -t raniac/neuro-learn-website:dev .
docker build -t raniac/neuro-learn-service:api .
docker build -t raniac/neuro-learn-service:ml .
docker build -t raniac/neuro-learn-service:sgn .

## !!!! PUSH IMAGES !!!!

docker push raniac/neuro-learn-website:dev
docker push raniac/neuro-learn-service:api
docker push raniac/neuro-learn-service:ml
docker push raniac/neuro-learn-service:sgn

docker push raniac/neuro-learn-env:api
docker push raniac/neuro-learn-env:ml
docker push raniac/neuro-learn-env:sgn

## !!!! INITIATE CONTAINERS FOR DEV !!!!

docker run -it --rm --network host -v /home/raniac/dev/NEURO-LEARN-DOCKER/services/api:/nls-api neuro-learn-service:api /bin/bash
docker run -it --rm --network host -v /home/raniac/dev/NEURO-LEARN-DOCKER/services/ml:/nls-ml neuro-learn-service:ml /bin/bash
docker run -it --rm --network host -v /home/raniac/dev/NEURO-LEARN-DOCKER/services/sgn:/nls-sgn neuro-learn-service:sgn /bin/bash
Automated Build
Automated Build
  • Modify code and commit to local git;
  • Push local git to online repository;
  • Create pull request and merge dev branch into master;
  • Which triggers automated build in DockerHub;
  • Successfully built images are ready to be pulled and deployed.
Automated Tests
  • Unit Tests
  • Functional Tests
  • Integrated Verification
Automated Deployment
  • Stand-Alone Deployment: docker-compose
$ docker-compose -f docker-compose.yml up -d
# docker-compose.yml
version: '2'

services:
  website:
    image: raniac/neuro-learn-website:dev
    # restart: on-failure
    network_mode: host
    container_name: website-dev

  service-api:
    image: raniac/neuro-learn-service:api
    # restart: on-failure
    network_mode: host
    container_name: service-api

  service-ml:
    image: raniac/neuro-learn-service:ml
    # restart: on-failure
    network_mode: host
    container_name: service-ml

  service-sgn:
    image: raniac/neuro-learn-service:sgn
    # restart: on-failure
    network_mode: host
    volumes:
      - /home/raniac/dev/NEURO-LEARN-DOCKER/services/sgn/models:/nld_sgn/models
    container_name: service-sgn
  • Clustered Deployment: kubernetes

Operations

  • healthcheck
    • Add healthcheck api for heartbeat detection and hence service registration/discovery;
    • Also used for unit test.
  • log
    • Run docker container with parameter: -v /opt/nls/{serviceName}/log:/{serviceRoot}/log or configure it in docker-compose.yml.

NEXT...

Towards Cloud Native.

References

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
禁止转载,如需转载请通过简信或评论联系作者。
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 194,524评论 5 460
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 81,869评论 2 371
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 141,813评论 0 320
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 52,210评论 1 263
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 61,085评论 4 355
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 46,117评论 1 272
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 36,533评论 3 381
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 35,219评论 0 253
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 39,487评论 1 290
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 34,582评论 2 309
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 36,362评论 1 326
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 32,218评论 3 312
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 37,589评论 3 299
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 28,899评论 0 17
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 30,176评论 1 250
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 41,503评论 2 341
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 40,707评论 2 335