未经许可请勿转载。
Please do not reprint this article without permission.
- Repository: GitHub/NEURO-LEARN-DOCKER
- Full-Text: https://rdcu.be/b4NCq
- Citation: Lei, B., Wu, F., Zhou, J. et al. NEURO-LEARN: a Solution for Collaborative Pattern Analysis of Neuroimaging Data. Neuroinform (2020). https://doi.org/10.1007/s12021-020-09468-6
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
Goals and BenefitsIn 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
The principles of microservice design are as follows:
- Self-Administration
- Stateless Services
- Communication with APIs
- Forward/Backward Compatibility
- Hierarchical/Acyclic Dependency
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.
DevOpsDevelopment, 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-LEARNNLD as Microservices
raniac/neuro-learn-website:dev
raniac/neuro-learn-service:api
raniac/neuro-learn-service:ml
raniac/neuro-learn-service:sgn
NLD with DevOps
- Standardized Runtime Container
- Standardized Development Process
- Standardized Image Building
- Decoupling and Incrementality
Version Control
Git
- Repository:
GitHub/NEURO-LEARN-DOCKER
; - Branches:
master
,dev
, etc.; - Collaboration: pull/merge requests.
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 indocker-compose.yml
.
- Run docker container with parameter:
NEXT...
Towards Cloud Native.
References
- Martin Fowler. Microservices
- Irakli Nadareishvili, Ronnie Mitra, Matt McLarty & Mike Amundsen. Microservices Architecture, Aligning Principles, Practices, and Culture
- Jennifer Davis, Katherine Daniels, Effective DevOps, Building a Culture of Collaboration, Affinity, and Tooling at Scale
网友评论