Professional Documents
Culture Documents
CT027-3-3-EPDA - Individual Assignment - UC3F1812SE
CT027-3-3-EPDA - Individual Assignment - UC3F1812SE
Table of Contents
Assumptions.................................................................................................................................... 2
1.4 Discussion on the role of Microservices in the distributed web application ...................... 12
References ..................................................................................................................................... 57
1
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Assumptions
2
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
3
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Based on the definition, we can see distributed systems having two features which is that
a distributed system is a collection of computing elements that can be independently of each other
or also known can be refer to as a node. The second feature would be how users perceive it as a
single system. Certain characteristics such as “no common physical clock” and “geographical
separation” has explained how computers can be said to be distributed. Especially “no common
physical clock” as it introduces the element of “distribution” into the system and that has given
rise to the inherent asynchrony nature among processors (Kshemkalyani & Singhal, 2007). The
image below provided an illustration for the definition provided by A. Goscinski:
4
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
A typical distributed computing system is shown in figure 1.0 whereby the computers are
equipped with memory processing unit and connected by a communication network. If we assume
these distributed systems to be able to perform high performance computing tasks, two subgroups
could be formed which are cluster computing and grid computer. These concepts make up the basis
of distributed computing or high-performance distributed computing. Cluster computing requires
the underlying hardware that consist of collection of similar workstations and are connected using
high-speed-local-area network (Steen & Tanenbaum, 2017). While grid computing is federation
of computer systems where each system could fall in different administrative domain and may
have different hardware, software or deployed network technology (Steen & Tanenbaum, 2017).
Grid computing is a form of distributed computing that supports parallel programming on a
network of variable size computers. The main goal is to solve difficult computational problem as
quickly as possible while reducing the cost compared to conventional methods. Some example of
grid computing includes particle accelerator and collider built by European Organization of
Nuclear Research (CERN) and SETI (Ghosh, 2007).
5
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
approach also promotes scalability as user could increase computational power by just adding more
processing core instead of investing in a single superfast uniprocessor. Lastly, computing systems
that built around a single node are prone to complete collapse when the processor fails, this risky
nature has given rise to distributed computing. By incorporating redundant processing which can
be seen in distributed computing, a system’s reliability or availability could be increased (Ghosh,
2007).
1. Client/Server
2. Service Oriented Architecture (SOA)
6
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
With further distinguishing between client/server, it is possible to turn a server into a client
whereby the processing layer could be executed by a separate server and distribute it across client
and server machines. This makes a three-tiered architecture and eventually creating a horizontal
distribution (Steen & Tanenbaum, 2017). As client or server could be split up into logically
equivalent parts and each part could operate its fair share of data set thus balancing the load, this
process is also known as peer to peer systems. The peer to peer paradigm then came to ease file
sharing among different hosts other than the server itself which resulted in a reduced latency
caused by centralized server. These paradigm shift could overcome limitation of client server in
achieving higher processing power (Gital, et al., 2014).
More than that, recommendation to include a middleware between servers and various
clients enabling them to integrate with the system soon took place, resulting in Service Oriented
Architecture. It is an evolution of client/server model as it allows services to be loosely coupled,
reusable and dynamically adapts to changing environment (Ismail, et al., 2000). SOA separates
various services, so they can operate independently. Distributed system is constructed with
composition of many different services such as storage. For example, business application could
make use of the cloud storage that is offered by cloud provider and these cloud storages are just
completely encapsulated into a single unit with the interface made available to customers (Steen
& Tanenbaum, 2017). In this part of development of distributed computing, problem comes from
service composition and making sure that these services operate in harmony. SOA centralizes the
7
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
complex operations such as business constraints and service orchestration all in the ESB. This
created a monolith of reusable services, but it will not be able to keep pace of customers and
business expectations (Newman, 2015). A monolith is a software application whose modules connt
be executed independently. This makes monoliths difficult to use in distributed system without
specific framework (Dragoni, et al., 2017). In other words, SOA isn’t scalable when resources are
few and highly demanded. Through SOA, it is difficult to understand the ways to split highly
complex system into small sub system. With such drawbacks, came the rise of microservices.
How does the size of a microservice defined? Lines of codes (LOC) can be an indicator
(Wolff, 2016). One of its problem using this approach is that it would depend on the programming
language used. Some languages require more code than others to express the same functionality.
More than that, microservices is seen as an architecture approach thus it should follow the
condition of the domain without adhering to technical metrics like LOC. LOC and the size of the
microservices can be influenced by several factors such as modularization, team size, or distributed
communication.
8
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Team size deals with the effort taken by the team to implement features within a
microservice and deploy these features into production independently of other teams. Team size
sets the upper limit for the size of microservices. When microservices are small, a team can be
responsible for several microservices only. When a microservices reaches a size that prevents its
further development by a single team, its too large. A typical team should be 3 to 9 people. The
teams are supposed to work and bring software into production independently of each other
whereby each team work on a separate microservice (Wolff, 2016).
9
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Architecture
An example is the Event-driven architecture whereby each microservices call each other
in order to implement shared logic. A microservice architecture is a distributed application where
all modules are microservices (Wolff, 2016). For example, at the end of the order process the
microservice for billing as well as the microservice for the order execution can be called to create
the bill and make sure that the ordered items are indeed delivered in figure 4.
Event-driven architecture (EDA) enables a different modelling in figure 5: When the order
processing has been successfully finished, the order process will send an event. It is an event
emitter. This event signals all interested microservices that there is a new successful order. Thus,
one microservice can now print a bill, and another microservice can initiate a delivery (Wolff,
2016).
10
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
EDA promotes loose coupling and facilitate changes as each microservice need to know little about
each other. For figure 5, other microservices which are interested in order could easily register
without modifying the order process.
11
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
There are many key benefits in using microservices when applied key concepts behind
distributed systems are considered. Below is a list of some of its key benefits and will be discussed:
1. Technology Heterogeneity
2. Scaling
12
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
3. Ease of Deployment
Technology Heterogeneity
In order to fit the current business needs, a system would be composed of multiple,
collaborating services and through the use of microservices, different technology can be used
inside each one. If one part of the system requires an improve in performance, then the old
component could be swap with different technology stack that is better able to achieve the
performance levels required. With microservices, technology could be adopted more quickly and
understand how new advancement could be beneficial (Newman, 2015).
Scaling
Ease of Deployment
Microservices allows changes to a single service and deploy it independently of the rest of
the system. Not just deployment, it also encourages fast rollback if there’s any problem because
individual service can be isolated easily. New functionality could reach out to customer more
quickly for large organization (Newman, 2015).
13
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
14
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Benefits
Spring Boot starters enable developers to specify build dependencies by what they offer rather
than the use of explicit library names and version. More than that, Spring Boot makes configuration
parameters and abstracts many lower level implementations, it minimizes the chance of error to a
certain extent. Spring Boot recognizes the nature of the application based on the libraries available
in the class path and runs the autoconfiguration classes packaged in these libraries (RV, 2016).
In Figure 5, Spring Boot framework understands that the project is set to use the Spring Data JPA
and HSQL databases. It automatically configures the driver class and other connection parameters
(RV, 2016).
Drawbacks
Architecture
15
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
between microservices through a message broker or event bus. Others can subscribe to events for
which they are interested and react to them. An important concept that is related: an action that
already happened, others can’t change it and can’t prevent it from happening. Any system that uses
this architecture also known as reactive systems because of the action-reaction pattern (Macero,
2017). A sample of Event-Driven Architecture that is applied to an application:
Spring MVC is the most popular Java Web framework based on the Model View Controller
(MVC) design pattern. Spring Boot makes it very easy to get started with Spring MVC because
the Spring Boot autoconfiguration mechanism configures most of the components such as
DispatcherServlet, ViewResolvers, ContentNegotiatingViewResolver etc, with default values and
provides the options to customize them. Spring Boot provides embedded servley container support,
so application could be built in a self-contained deployment unit (Reddy, 2017). Spring Boot
provides the Web starter spring-boot-starter-web for developing web applications using Spring
MVC.
16
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
17
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
It contains sets of powerful libraries that are well suited for web development such as (Copperwaite
& Leifer, 2015):
Template rendering with Jinja2, one of the most powerful Python template engines
Easy-to-use, flexible application configuration management
URL routing that makes it easy to map URLs to your code
With these features, it can handle Ajax requests, browser requests, and user sessions between
request and so on. Flask would be used to combine with Werkzeug and Jinja2 frameworks. It is
also responsible for answering requests and presenting the output (Maia, 2015).
Architecture
As covered in Spring Boot Framework, Flask can also be used in MVC architecture
whereby it would only cover C and V. But it will not be able to work with integrated model layer
out of the box, but it does accept database solution from another model layer (Maia, 2015). Flask
18
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
can maximise the use of Jinja2 to implement the View layer of an MVC architecture. For example,
consider a user who is registering a new account on a website. The user types an email address and
a password in a web form and clicks the Submit button. On the server, a request that includes the
data from the user arrives and Flask dispatches it to the view function that handles registration
requests. This view function needs to talk to the database to get the new user added and then
generate a response to send back to the browser. These two types of tasks are formally called
business logic and presentation logic. Code would be hard to understand and maintain if both
logics are mixed together. Thus, the presentation logic will be move into templates. A template is
a file that contains the text for a response, placeholder variables for dynamic parts known only in
the context of a request. This placeholder variables is called rendering and this powerful template
is called Jinja2 (Grinberg, 2014). Jinja2 can be use with template files or string in order to create
formatted text such as HTML, or Markdown. It can be used to put together, reuse, and extend
template (Maia, 2015). An example uses of template called user.html that can be called in
render_template function for representing a variable with its response:
Flasks looks for predefined templates in templates subfolder located within an application folde.
Figure 11: user.html template use to call the response (Grinberg, 2014)
19
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
20
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
1) JSPs
2) Servlets
Before going into the implementation, it is essential to have a bird’s eye view of JSP and Servlet
and understand their importance.
JSP
JavaServer Pages or also known as JSP is one solution to providing dynamic Web content
(Marco, 2001). Without JSP, to update the appearance or the content of plain static HTML, it must
be done manually. Through JSP, content dependent on many factors could be achieved including
time of the day, the information provided by the user, the user’s history of interaction with the
website and even the browser’s type. It provided online services in which it can be tailored to each
response for the viewer who made the request, depending on their preference and requirements
(Zambon, 2012). Customers want and expect some sort of personalization from sites they visited.
It contains both HTML and JSP tags but it is still a text document (Wolf, 2017). JSP combines
static text with special JSP tags and these static texts represent invariant parts of the Web page.
The static text and the JSP tags will be sent to a Java-enabled server that generates HTML from
both static and JSP tag. The server would send generated HTML back to the browser for display
and continued user interaction.
JSP files typically have a .jsp extension, such as home.jsp. The extension allows JSP-enabled
server to recognize it as a JSP page and in turn processes the special tags as JSP tags (Marco, 2001).
Figure below shows JSP can be viewed by a user. With JSP, the web page will not exist on the
server as the server creates it fresh when responding to each request.
21
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
How does it work? Based on the book by Giulio Zambon, it provided a brief description on the
steps involved:
1. The browser or the user operating the web browser can send an HTTP request to the web
server. The URL would end in .jsp, for example home.jsp.
2. This web server is not a normal server, but it is a Java server with the necessary extensions
to identify and handle java servlets. The web server would recognize the HTTP request is
for a JSP page then forwards it to a JSP engine.
3. The JSP engine would load the JSP page from disk and converts it into a Java Servlet. The
servlet is indistinguishable from another servlet developed by Java rather than JSP, but the
Java code of a JSP servlet is not easy to read or modified.
4. The JSP engine complies the servlet into an executable class and forwards the original
request to another servlet engine.
5. The servlet engine loads the servlet class and executes it. During execution, the servlet
would produce an output in HTML format which the servlet engine passes to web server
inside the HTTP response. The servlet has Java println statements that write the static text
to the output stream and Java code that implements the functionality of the JSP tags (Marco,
2001).
6. Browser would receive the forwarded HTTP response from the web server.
7. The dynamically generated HTML page inside the HTTP response would be handled by
the web browser as a static page.
22
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
The JSP file involved is called login.jsp. Below is a code snippet of the JSP page whereby it
receives user inputs (Username and Password) and submit the JSP page to server with a “POST”
service. The ACTION attribute of the HTML form specified the action upon submitting the form
is to send the name of a JSP page with the two parameters to the server. This would cause the JSP-
enabled server (Login.java) to recognize the .jsp extension and takes appropriate action. In this
case, the servlet would take the necessary action depending on the parameters and forward it to
relevant JSP page involved.
23
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
24
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
25
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Servlet
The controller is housed in the Java Servlets. The controller layer contains code to handle
application-specific logic. This includes request such as receiving data from web pages, sending
data to classes in service layer and sending the user to next servlet or JSP. Where else the controller
does not access the database directly, but in the project’s case, it’s through the facades (Wolff,
2016).
Servlets are Java Classes that respond to incoming HTTP requests. The request is sent by
browser through actions such as submitting a form. The servlet will get respond and process the
request. Because the servlet only has two methods, doGet and doPost, they correspond to the get
or post method of a form respectively (Wolf, 2017). The servlets implement javax.servlet.Servlet
interface (Perry, 2004). Below is a sample code snipper of the Register.java class.
26
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
1) Customer
2) Admin
3) Staff (Delivery and Reservation)
The Delivery and Reservation staff share similar pages with admin but some of it has restricted
functionality. Thus, the user manual would include a note if the view is present in delivery or
reservation staff to reduce redundancy.
2.2.1 Customer
1) Login
27
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
2) Register
3) Home Screen
28
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
4) Profile
Reservation and delivery staff is also able to edit their profile using the same method.
5) Edit Profile
29
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
6) Making Order/Delivery
30
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
8) History
9) Top Up Wallet
2.2.2 Admin
1) Admin Page
2) Customer
33
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
5) Edit Customer
34
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
6) View/Add Staff
7) Edit/Delete Staff
35
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
36
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
9) View/Add Foo
37
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
38
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
The EJB component model consisted of three objects types that developers may build or
customize:
1) Session beans
2) Message-driven beans
3) Entities (Java Persistence API)
Session beans and Message-driven beans are considered to be enterprise beans. In earlier version
of EJB, entities are referred to as entity beans, but recent version has set entities to be managed by
39
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
persistence provider and not EJB container, thus no longer considered as enterprise beans
(Wetherbee, et al., 2018).
Session beans
Session beans provided a model for the business process of the Java Application and
encapsulate a business logic for each process. They are Java components that run on EJB container
which is typically used to model a task such as entering customer information or implementing a
process that maintains a conversation state with client application. Some use cases to hold business
logic includes the order entry and expense reporting applications (Wetherbee, et al., 2018). Which
in the project’s case, it is used for food order entry, human resource etc. In human resource, it
creates a new employee and assigns the employee to a particular department.
Session beans has three types which is stateless, stateful and singleton. Stateless bean does
not maintain any conversational state on behalf of the client application. Where else, stateful
maintains a state and an instance of the bean which is tied to a specific client request. It runs on
server and can be seen as an extension to client program. Lastly, the singleton is instantiated only
once for a single application. It lives only for the full duration of an application and maintain the
state between each invocations (Wetherbee, et al., 2018). Figure below shows session beans in a
3-tier architecture with a web application:
Figure 40: 3-tier architecture with a web application (Wetherbee, et al., 2018)
Message-Driven Beans
Messaging is one of the viable solutions for integrating existing and new applications in an
asynchronous communication and loosely coupled transaction model. This allow the application
40
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
to avoid waiting for the receiver when sending a message because both sender and receiver
understand the message format.
- Message-driven class
- Optional callback listener class
- Optional interceptor class
Figure 41: Sample Message-driven Bean use case (Wetherbee, et al., 2018)
41
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
MVC promotes code reuse and maintainability. In reusability, the application’s logic
implementation in the model and controller gets reused for each different view. More than that,
the code is in independent units and can be maintained without fully understanding the entire
application (Wolf, 2017).
42
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
JSP (View)
43
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
Servlet (Controller)
44
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
45
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
46
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
1) FoodDetails
2) StaffDetails
3) TempFoodOrder
4) UserAccount
5) UserMoney
1. Food Details
Stores food information such as the id, name, price, quantity, description and its type
(Food/Drinks).
47
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
48
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
2. Staff Details
Staff Details act as the human resource database that stores information such as id, password,
staff name, staff gender, phone, ic, email, address, his/her role and status.
49
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
50
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
3. TempFoodOrder
Stores information regarding the food order and allows reservation staff and admin to approves
the order. Information such as id, userid, foodids’, orderdatetime, price, address,status, quantity,
deliverystatus, deliveryman.
51
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
52
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
4. UserAccount
Stores information about the user/customer such as username, password, name, ic, gender, phone
number, email, address, status, UserMoney.
53
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
54
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
5. UserMoney
55
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
UserMoney
PK id
PK id
foodname
balance
price
quantity
description
StaffDetails
TempFoodOrder foodtype
UserAccount PK id
PK id
PK id
password
userid
password
staffname
orderdatetime
name gender
price
ic phone
address
gender ic
status
phoneno email
quantity
email address
deliverystatus
address staffrole
deliveryman
status staffstatus
foodid
56
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
References
6. Aggarwal, S., 2014. Flask Framework Cookbook. 1 ed. Birmingham: Packt Publishing Ltd..
7. Copperwaite, M. & Leifer, C., 2015. Learning Flask Framework. 1 ed. Birmingham: Packt
Publishing Ltd..
10. Ghosh, S., 2007. Distributed Systems An Algorithmic Approach. 1 ed. New York: Taylor
& Francis Group, LLC.
12. Goscinski, A., 1991. Distributed Operating Systems: The Logical Design. 1 ed. Boston:
Addison-Wesley Longman Publishing Co., Inc.
13. Grinberg, M., 2014. Flask Web Development. 1 ed. Sebastopol: O’Reilly Media, Inc.
14. Ismail, L., Hagimont, D. & Mossire, J., 2000. Evaluation of the mobile agents technology:
Comparison with the client/server paradigm. Information Science and Technology (1ST),
Volume 19.
16. Macero, M., 2017. Learn Microservices: A Practical Approach to RESTful Services using
RabbitMQ, Eureka, Ribbon, Zuul and Cucumber. 1 ed. New York: pringer
Science+Business Media New York.
57
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
17. Maia, I., 2015. Building Web Applications with Flask. 1 ed. Birmingham: Packt Publishing
Ltd..
18. Marco, L., 2001. EJB & JSP: Java On The Edge,. Unlimited Edition ed. s.l.:Wiley.
20. Newman, S., 2015. Building Microservices: Designing Fine-Grained System. 2 ed.
California: O’Reilly Media, Inc..
21. Perry, B. W., 2004. Java Servlet & JSP Cookbook. 1 ed. s.l.:O'Reilly.
22. Reddy, K. S. P., 2017. Beginning Spring Boot 2: Applications and Microservices with the
Spring Framework. 1 ed. Hyderabad: Springer Science+Business Media New York.
23. RV, R., 2016. Spring Microservices: Build scalable microservices with Spring, Docker,
and Mesos. 1 ed. Birmingham: Packt Publishing Ltd..
24. Salah, T. et al., 2016. The Evolution of Distributed Systems Towards Microservices
Architecture. The 11th International Conference for Internet Technology and Secured
Transactions (ICITST-2016).
25. Steen, M. v. & Tanenbaum, A. S., 2017. Distributed Systems. 3 ed. s.l.:Maarten van Steen.
26. Villamizar, M. et al., 2017. Cost comparison of running web applications in the cloud using
monolithic, microservice, and AWS Lambda architectures. Service Oriented Computing
and Applications, 11(2), pp. 233-247.
27. Walls, C., 2016. Spring Boot In Action. 1 ed. New York: Manning Publications Co..
28. Wetherbee, J., Nardone, M., Rathod, C. & Kodali, R., 2018. Beginning EJB in Java EE 8:
Building Applications with Enterprise JavaBeans. 3 ed. New York: Springer
Science+Business Media New York.
29. Wolf, D., 2017. Java EE Web Application Primer Building Bullhorn: A Messaging App
with JSP, Servlets. JavaScript, Bootstrap and Oracle. 1 ed. NewYork: Springer
Science+Business Media New York.
58
CT027-3-3-EPDA | Individual Assignment | UC3F1812SE
30. Wolff, E., 2016. Microservices: Flexible Software Architecture. 1 ed. Boston: Pearson
Education, Inc.
31. Wong, G., 2019. Screenshot of Code Snippets. Kuala Lumpur: s.n.
32. Zambon, G., 2012. Beginning JSP, JSF and Tomcat. 1 ed. New York: Springer
Science+Business Media New York.
59