USING MICROSERVICES ARCHITECTURE AS ANALYTICAL SYSTEM FOR ELECTRICAL IMPEDANCE TOMOGRAPHY IMAGING

An image reconstruction with use of EIT method has been found useful in many areas of medical, industrial and environmental applications. Papers show that computational systems used for image reconstructions are utilizing parallel and distributed computations and multi-tier architecture, as well as monolithic architecture. The aim of our research is to define an analytical system architecture that will be able to combine a variety of image reconstruction algorithms with their representations in different programming languages. Based on examples described in different proceedings and research papers, a microservices architecture seems to be an interesting alternative to the monolithic one.


Introduction
Electrical Tomography is a relatively mature imaging method that can be useful in medical, industrial and environmental applications to discover the inner structure of an investigated object [11,16,[23][24][25][26][27].
The image reconstruction in EIT is a highly ill-posed inverse problem [2,[7][8][9][17][18][19][20][21].To solve the EIT inverse task, several algorithms are well known and used.They can be split into two categories: direct algorithms and iterative ones.There are few recognized as ready to use for commercial applications (e.g.GREIT) [1] and many that are in continuous development, therefore risky to use.Every case of an image reconstruction consists of almost the same number of steps beginning from data acquisition, data analysis by means of different methods, and ending with a visualization.Using such assumption and combining information about similar researches carried out on analytical systems applications on different research fields [4,12,13], a thesis was formulated, that it is possible to use architecture based on microservices to combine various image reconstruction methods in one analytical system.

Monolithic approach to analytical system design
Till now, the natural way to create analytical system was to build a monolithic web application.
That design was used to create a prototype of system for tomography analysis.The basic assumption was made to build an application which will gather data from devices, preserve and analyze them, and accomplish basic visualizations.Additionally, application could monitor tomographic device status.
The system consisted of four layers, as shown in Figure 1.The data was acquired from tomographic devices as time series datasets.In this stage MQTT protocol was used to pass the data from the source to the analytical system.
The data flow (Figure 2) was replicated into two flows: the first one was sent to the database system (for this purpose NoSQL Cloudant database system was used) and the second one was sent to the analytical system for further analysis.The aim of such operation was to process data in real time as well as to keep raw historical data for additional offline analysis.The analytical system in form of web application (Figure 3) was built on top of IBM Bluemix PaaS platform.The advantage of this platform is easy integration with other analytical services like IBM Data Scientist Experience, which allows to use additional analytical methods from Apache Spark framework for further data analysis.
Monolithic application is a good approach, however, it had certain limitations.It was quite difficult to combine in one analytical stage few different algorithms written in different languages, which could be very useful for image reconstruction.The structure of such system also caused difficulties in extending analytical layer with additional methods, because it involved rewriting these methods in supported language or doing plumbing between system and additional methods libraries.The solution was scalable in means of adding additional application instances, memory, CPU etc. but it affected whole system due to monolithic nature, so there wasn't possible to scale only a part of the system (e.g.analytical resources).General problems with monolithic architecture:  code becomes harder to maintain and test as it grows larger,  coupling between modules causes random bugs when changes are made,  deployments and upgrades require application downtime,  if part of a service crashes then entire site goes down,  difficulty in application scaling,  incorporating new technologies is rather difficult.

Modular approach to analytical system design
The analytical system should easily deal with a variety of data sources, analytical methods, as well as many different types of users' applications.Taking into consideration the use cases and requirements of different analytical systems applications, the common features can be summarized as: need of easy deployment and monitoring, possibility of replacement of system components (if they are malfunctioned or a new version appears), reliability, flexibility and fault-tolerance.Experience brought from an industry (a good example is Netflix service) shows rapid change in applied, distributed systems architecture from building monolithic applications to adopting microservice architecture [5,6,14].While the fundamental concepts of microservices are not new, sometimes they can be wrongly treated as SOA architecture, but in fact they are something different [5].The aim of creating microservices concept was to eliminate unnecessary complexity and implement single functionality in one small and independent service.They can communicate with each other using mechanisms such as HTTP-based RESTful APIs.The adoption of microservices is driven by scalability challenges, lack of efficiency, slow development and difficulties with adoption of new technologies that arise in case of complex software systems, constructed as one huge monolithic application.After Martin Flower, it can be said that microservices are not only philosophy of designing systems but also a new way to cooperate with clients [10].
Microservices mean not only easiness and lack of problems caused by monolithic architecture.In case of heavily distributed system, developers need to follow strictly the design assumptions and keep standardization of the architecture.There are many patterns telling how the system should be built and decision of choosing one best for the designed system could be problematic.Adding to the bucket the variety of technologylanguages, frameworks, deployment solutionscan cause the design process of a system based on microservices complicated [15].On the other hand, the simplicity in the scaling of an application can repay a hard work.The deployment on microservices can be done easily with use of containerization technologies like a Docker [3].Docker container contains everything required to run a softwarecode, runtime environment, system tools, libraries and settings.This ensures that the software will run the same way, regardless of where it's deployed.When the solution is divided into microservices and deployment procedure operates on containerization it is one step away from moving such system to a cloud computing environment [22].

The work aim
Nowadays, during a development stage of analytical systems, there are few requirements for the designed systems that should be taken into consideration:  they should be reachable for every researcher,  they are supposed to be scalable and easy extendable.
Analytical systems are utilized in every kind of business and industry.In case of the research on electrical tomography, one of the main parts of the system is an images reconstruction system.The measurement system and analytical system are separated in natural way.Also, modules of computational system can be divided into layers and analytical layer can be split into smaller parts including image's reconstruction methods.Each reconstruction method module should be easy to use and to replace.
Additionally, the system must be scalable in various ways.Need of scalability depends on a size of measurement systemmicroscale can consist of one measurement device but the same reconstruction system should be able to work with hundreds measurement sets.Such assumptions conduct one to look for the solution in a set of distributed systems architectures.
The summarization of system requirements gives a conclusion that all properties of building systems will be achieved with application of microservices architecture.Benefits of incorporating to the system the microservices architecture is as follows:  if microservice crashes, the rest of the system will keep going,  deployment doesn't require downtime of any part of the system,  each microservice can be scaled individually according to its needs,  services can use different technical stacks (i.e.programming language, runtime engine, operating system)  code complexity is reduced.
This new approach is focused on analytical engine, as seen in Figure 4. Every single functionality is contained within one separated microservicethat is the premise and goal for the rebuilt system.In the case the system's rebuild one can assume several scenarios:  adding new microservices when development is moving forward with application,  breaking pieces of functionality into microservices over time,  refactoring the entire system into microservices at once.

. Component diagram of image reconstruction case with application of GREIT algorithm
While the first two approaches are feasible, the latter was not appropriate in case of the presented research.
Ultimately, microservices are communicating with each other and the rest of the system using message broker, which accept messages, queue them up and route them to destination(s).These analytical modules have they own APIs which expose calculation results to the system clients.In fact, the calculation result may be an image reconstruction matrix, which can be used by such libraries, like D3.js, to visualize a reconstruction image (in this case MPLD3 library was used).More detailed diagram of the system is shown in Figure 5.The core of the system is included in analytical system domain and user functionality is located inside users' domain.
Those two subsystems communicate with each other using RESTful API and data is exchanged in JSON format.To use the system, first, user must create a unit called Research.It is used as a container to store different researches carried by the same user.Each research can consist of many different experiments with different properties, like different source of data as well as variety of reconstruction methods.After setting research arguments and experiment properties user can run the experiment.As a result of the experiment, reconstruction of an image is ready for further processing.The final step is displaying the reconstruction image on the user's application on the device.User decides about the form in which the reconstruction data will be depicted (e.g. in web or mobile application) due to RESTful API.Modular system design allows to rebuild system easily, providing that the RESTful API and data format stays the same.Application of microservices permits using of polyglot programming, i.e. multiple programming languages inside one computational system.
Taking into consideration more detailed data flow, which is shown in Figure 6 (see page below), one can see some example of data analysis procedure.In the simplest case, data is gathered from EIT device and then stored in database (i.e.NoSQL database).Next, reconstruction algorithm consume data brought from data source and produce the reconstruction image.The image is presented on a web page.In this case only two microservices are used: one as data source and one for image reconstruction.The data source microservice is written in JavaScript using Node.jsframework and the other is implemented in Python with Flask library.

Conclusions
The difference between monolithic and modular approaches to build an analytical system was shown.One comes to conclusion that monolithic application is good for research starting point, but quickly it becomes very restrictive in many areas.
An important factor in the use of architecture is the ability to verify the operation of different reconstruction algorithms running at the same time.To date, such experiences have been difficult.
An important feature of the analytical system based on microservices is its resistance to failures due to faulty analysis modules.In this case, failure of one analytical module does not cause the entire system to shutdown.What in the case of a monolithic system leads to the closure of the entire system.This solution works with IBM Bluemix cloud computing system.By using the PaaS model, each microservice can receive virtually unlimited hardware resources.The number of running micro-instances and resources such as memory, processor type can be dynamically changed during system operation.In the case of a monolithic applications, such operations are difficult to carry out.
In the presented research, the main problem with a monolithic application was a lack of easy extensibility in adoption of analysis algorithms written in different programming languages.What, as shown, can be bypassed by changing the application architecture and use of microservices.

Fig. 2 .
Fig. 2. Data flow inside of the system