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

未經(jīng)許可請勿轉(zhuǎn)載。
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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
禁止轉(zhuǎn)載纹份,如需轉(zhuǎn)載請通過簡信或評論聯(lián)系作者庞萍。
  • 序言:七十年代末祸挪,一起剝皮案震驚了整個濱河市禀晓,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌箕肃,老刑警劉巖婚脱,帶你破解...
    沈念sama閱讀 219,366評論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異勺像,居然都是意外死亡障贸,警方通過查閱死者的電腦和手機,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,521評論 3 395
  • 文/潘曉璐 我一進店門吟宦,熙熙樓的掌柜王于貴愁眉苦臉地迎上來篮洁,“玉大人,你說我怎么就攤上這事殃姓≡ǎ” “怎么了?”我有些...
    開封第一講書人閱讀 165,689評論 0 356
  • 文/不壞的土叔 我叫張陵蜗侈,是天一觀的道長篷牌。 經(jīng)常有香客問我,道長踏幻,這世上最難降的妖魔是什么枷颊? 我笑而不...
    開封第一講書人閱讀 58,925評論 1 295
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上夭苗,老公的妹妹穿的比我還像新娘信卡。我一直安慰自己,他們只是感情好听诸,可當(dāng)我...
    茶點故事閱讀 67,942評論 6 392
  • 文/花漫 我一把揭開白布坐求。 她就那樣靜靜地躺著蚕泽,像睡著了一般晌梨。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上须妻,一...
    開封第一講書人閱讀 51,727評論 1 305
  • 那天仔蝌,我揣著相機與錄音,去河邊找鬼荒吏。 笑死敛惊,一個胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的绰更。 我是一名探鬼主播瞧挤,決...
    沈念sama閱讀 40,447評論 3 420
  • 文/蒼蘭香墨 我猛地睜開眼,長吁一口氣:“原來是場噩夢啊……” “哼儡湾!你這毒婦竟也來了特恬?” 一聲冷哼從身側(cè)響起,我...
    開封第一講書人閱讀 39,349評論 0 276
  • 序言:老撾萬榮一對情侶失蹤徐钠,失蹤者是張志新(化名)和其女友劉穎癌刽,沒想到半個月后,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體尝丐,經(jīng)...
    沈念sama閱讀 45,820評論 1 317
  • 正文 獨居荒郊野嶺守林人離奇死亡显拜,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 37,990評論 3 337
  • 正文 我和宋清朗相戀三年,在試婚紗的時候發(fā)現(xiàn)自己被綠了爹袁。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片远荠。...
    茶點故事閱讀 40,127評論 1 351
  • 序言:一個原本活蹦亂跳的男人離奇死亡,死狀恐怖失息,靈堂內(nèi)的尸體忽然破棺而出譬淳,到底是詐尸還是另有隱情,我是刑警寧澤根时,帶...
    沈念sama閱讀 35,812評論 5 346
  • 正文 年R本政府宣布瘦赫,位于F島的核電站,受9級特大地震影響蛤迎,放射性物質(zhì)發(fā)生泄漏确虱。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點故事閱讀 41,471評論 3 331
  • 文/蒙蒙 一替裆、第九天 我趴在偏房一處隱蔽的房頂上張望校辩。 院中可真熱鬧窘问,春花似錦、人聲如沸宜咒。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,017評論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽故黑。三九已至儿咱,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間场晶,已是汗流浹背混埠。 一陣腳步聲響...
    開封第一講書人閱讀 33,142評論 1 272
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機就差點兒被人妖公主榨干…… 1. 我叫王不留诗轻,地道東北人钳宪。 一個月前我還...
    沈念sama閱讀 48,388評論 3 373
  • 正文 我出身青樓,卻偏偏與公主長得像扳炬,于是被迫代替她去往敵國和親吏颖。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 45,066評論 2 355