0% found this document useful (0 votes)
72 views23 pages

7.web Application Architecture

This chapter covers various architectural designs for web applications, focusing on client-server communication, load balancing, and server management. It explains the role of load balancers, different load balancing algorithms, and the use of NGINX as a load balancer, along with setup instructions. Additionally, it discusses web servers like Apache and Tomcat, and introduces MySQL as a relational database management system.

Uploaded by

Aslam Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views23 pages

7.web Application Architecture

This chapter covers various architectural designs for web applications, focusing on client-server communication, load balancing, and server management. It explains the role of load balancers, different load balancing algorithms, and the use of NGINX as a load balancer, along with setup instructions. Additionally, it discusses web servers like Apache and Tomcat, and introduces MySQL as a relational database management system.

Uploaded by

Aslam Ansari
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

VII.

Web Application Architecture


This Chapter discusses a few architectural designs used for web applications. Each design provides
one or more examples architectural solutions for modern web Application.

1. WEB APPLICATION ARCHITECTURE 1

2. The Client
Web development is all about communication and sharing Information . In this case,
communication between two (2) parties, over the HTTP protocol:
The Server - This party is responsible for serving pages.
The Client - This party requests pages from the Server, and displays them to the user. In
most cases, the client is a web browser.
a. The User - The user uses the Client in order to surf the web, fill in forms, watch videos
online, etc.

3. Load balancing
Load balancing refers to efficient and skilful distribution of incoming network traffic across a group
of backend servers, also known as a server farm or server pool.
Modern high-traffic websites must serve hundreds of thousands, if not millions, of concurrent
requests from users or clients and return the correct text, images, video, or application data, all in a
fast and reliable manner. To cost-effectively scale to meet these high volumes, modern computing
best practice generally requires adding more servers.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
4. Load balancer
A load balancer acts as the “traffic cop” that act as traffic controller in front of your servers and
routing client requests across all servers capable of fulfilling those requests in a manner that
maximizes speed and capacity utilization and ensures that no one server is overloaded or
overworked, which could degrade performance of server or may let down the whole server. If a
single server goes down, the load balancer redirects traffic to the remaining online servers. When a
new server is added to the server group, the load balancer automatically starts to send requests to it.
In this manner, a load balancer performs the following functions:
Distributes client requests or network load efficiently across multiple servers
Ensures high availability and reliability by sending requests only to servers that are online
Provides the flexibility to add or subtract servers as demand dictates

5. Load Balancing Algorithms


There are different load balancing algorithms are available and each provide different benefits; the
choice of load balancing method depends on your requirement:
❖ Round Robin – Requests are distributed across the group of servers sequentially.
❖ Least Connections – A new request is sent to the server with the fewest current connections
to clients. The relative computing capacity of each server is factored into determining which
one has the least connections.
❖ IP Hash – The IP address of the client is used to determine which server receives the
request.

6. Dynamic Configuration of Server Groups


For a fast-changing application require new servers to be added or remove on a constant basis. This
is common in environments such as the Amazon Elastic Compute Cloud (EC2), which enables
users to pay only for the computing capacity they actually use, while at the same time ensuring that
capacity scales up in response traffic spikes. In such environments, it greatly helps if the load
balancer can dynamically add or remove servers from the group without interrupting existing
connections.

7. Hardware vs. Software Load Balancing


Vendors of hardware-based solutions load proprietary software onto the machine they provide,
which often uses specialized processors. To cope with increasing traffic at your website, you have
to buy more or bigger machines from the vendor. Software solutions generally run on commodity
hardware, making them less expensive and more flexible. You can install the software on the
hardware of your choice or in cloud environments like AWS EC2.
Note : Here we include Nginx as load balancer.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
8. NGINX / NGINX Plus As Load Balancer
NGINX Plus and NGINX are used by many developers for load balancing solutions for high-traffic
websites such as Dropbox, Netflix, and Zynga. NGINX Plus and NGINX to deliver their content
quickly, reliably, and securely. When you include NGINX Plus as a load balancer in front of your
application and web server farms, it increases your website’s efficiency, performance, and
reliability. NGINX Plus helps you maximize both customer satisfaction and the return on your IT
investments.

How To Setup Nginx As Load Balancer?


❖ Install nginx
The steps require the user to have root privileges on your virtual private server (VPS).Prior to
setting up nginx load balancing, you should have nginx installed on your VPS. You can install it
quickly with apt-get:
$ sudo apt-get install nginx

❖ Upstream Module
In order to set up a round robin load balancer, we will need to use the nginx upstream module. We
will incorporate the configuration into the nginx settings.
Go ahead and open up your website’s configuration (in my examples I will just work off of the
generic default virtual host):
$sudo nano /etc/nginx/sites-available/default

We need to add the load balancing configuration to the file.


First we need to include the upstream module which looks like this:
upstream backend {
server backend1.example.com;
server backend2.example.com;
server backend3.example.com;
}

We should then reference the module further on in the configuration:


server {
location / {
proxy_pass http://backend;
}
}

• Restart nginx
$ sudo service nginx restart

As long as you have all of the virtual private servers in place you should now find that the load
balancer will begin to distribute the visitors to the linked servers equally.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
❖ Directives
The previous section covered how to equally distribute load across several virtual servers. However,
there are many reasons why this may not be the most efficient way to work with data. There are
several directives that we can use to direct site visitors more effectively.

Weight
One way to begin to allocate users to servers with more precision is to allocate specific weight to
certain machines. Nginx allows us to assign a number specifying the proportion of traffic that
should be directed to each server.

A load balanced setup that included server weight could look like this:
upstream backend {
server backend1.example.com weight=1;
server backend2.example.com weight=2;
server backend3.example.com weight=4;
}

The default weight is 1. With a weight of 2, backend 2.example will be sent twice as much traffic as
backend 1, and backend 3, with a weight of 4, will deal with twice as much traffic as backend 2 and
four times as much as backend 1.

Hash
IP hash allows servers to respond to clients according to their IP address, sending visitors back to
the same VPS each time they visit (unless that server is down). If a server is known to be inactive, it
should be marked as down. All IPs that were supposed to routed to the down server are then
directed to an alternate one.
The configuration below provides an example:
upstream backend {
ip_hash;
server backend1.example.com;
server backend2.example.com;
server backend3.example.com down;
}

Max Fails
Based on default round robin settings, nginx will continue to send data to the virtual private servers,
even if the servers are not responding. Max fails can automatically prevent this by rendering
unresponsive servers inoperative for a set amount of time.
There are two factors associated with the max fails: max_fails and fall_timeout. Max fails refers to
the maximum number of failed attempts to connect to a server should occur before it is considered
inactive. Fall_timeout specifies the length of that the server is considered inoperative. Once the time
expires, new attempts to reach the server will start up again. The default timeout value is 10
seconds.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
A sample configuration might look like this:
upstream backend {
server backend1.example.com max_fails=3 fail_timeout=15s;
server backend2.example.com weight=2;
server backend3.example.com weight=4;

9. Apache HTTP Server


The Apache HTTP server i s free and open-source cross-platform web server software, released
under the terms of Apache. Apache is developed and maintained by an open community of
developers under the Apache Software Foundation. The project develops and maintains an open-
source HTTP server for modern operating system including UNIX and Windows . The Apache
HTTP web server is still the most used web server worldwide.

Windows:
Download Installer Apache HTTP server here: (http://httpd.apache.org/download.cgi)
Be sure to download the apache_2.2.16-win32-x86-no_ssl MSI.
Note :the Apache HTTP server version may be different at the time of your installation

Linux:
On Ubuntu you can install the Apache HTTP server with the following command.
$ sudo apt-get install apache2

10. Tomcat Server


Tomcat, is also developed by Apache (www.apache.org), is a standard reference implementation for
Java servlets and JSP. It can be used standalone as a Web server or be plugged into a Web server
like Apache, Netscape Enterprise Server, or Microsoft Internet Information Server. There are many
versions of Tomcat. Here we uses Tomcat 5.5.9 as an example. The same steps should also apply to
all later versions of Tomcat.

Note : For Using Tomcat we need JDK installed in our system


JDK Setup:
• This step involves downloading an implementation of the Java Software Development Kit
(SDK) and setting up the PATH environment variable appropriately.
• You can download SDK from Oracle's Java site − Java SE Downloads.
• Once you download your Java implementation, follow the given instructions to install and
configure the setup. Finally set the PATH and JAVA_HOME environment variables to refer
to the directory that contains java and javac, typically java_install_dir/bin and
java_install_dir respectively.
• If you are running Windows and install the SDK in C:\jdk1.8.0_60, you need to add the
following line in your C:\autoexec.bat file.
• Set PATH = C:\jdk1.8.0_60\bin;%PATH%
• set JAVA_HOME = C:\jdk1.8.0_60

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
Tomcat Installation:
Linux:
$ sudo apt-get install tomcat7

(Install the required version of tomcat)


Windows:
Download the latest version of Tomcat from https://tomcat.apache.org/.
Once you downloaded the installation, unpack the binary distribution into a convenient location.
For example, in C:\apache-tomcat-5.5.29 on windows, or /usr/local/apache-tomcat-5.5.29 on
Linux/Unix and create CATALINA_HOME environment variable pointing to these locations.

Starting Tomcat
Tomcat can be started by executing the following commands on the Windows machine −
%CATALINA_HOME%\bin\startup.bat
or
C:\apache-tomcat-5.5.29\bin\startup.bat

Tomcat can be started by executing the following commands on the Unix (Solaris, Linux, etc.)
machine −
$ cd CATALINA_HOME/bin/

$ ./startup.sh

or

$ cd /usr/local/apache-tomcat-5.5.29/bin/

$ ./startup.sh

After a successful startup, the default web-applications included with Tomcat will be available by
visiting http://localhost:8080/.

11. Database(MySQL)
A database is a separate application that stores a collection of data. Each database has one or more
distinct APIs for creating, accessing, managing, searching and replicating the data it holds. Other
kinds of data stores can also be used, such as files on the file system or large hash tables in memory
but data fetching and writing would not be so fast and easy with those type of systems.
Well, there’s tons of types of databases nowadays. Many companies develop their own databases to
adapt them to their needs.
First of all, there’s the relational databases, that’s where the industry started, they use table-like
schemes and store the data in disk. This kind of databases are pretty good to store business data. For
example MySQL, Postgres, SQL Server etc.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
Then there’s the NoSQL databases. This kind of databases cover a wide amount of technologies
where you can find key-value databases. Here you would find databases like MongoDB,
Cassandra, Neo4j etc.

Note: Here we used Mysql Relational Database


We use relational database management systems (RDBMS) to store and manage huge volume of
data. This is called relational database because all the data is stored into different tables and
relations are established using primary keys or other keys known as Foreign Keys.

A Relational DataBase Management System (RDBMS) is a software that −


Enables you to implement a database with tables, columns and indexes.
Guarantees the Referential Integrity between rows of various tables.
Updates the indexes automatically.
Interprets an SQL query and combines information from various tables.

MySQL
MySQL is the most popular Open Source Relational SQL Database Management System. MySQL
is one of the best RDBMS being used for developing various web-based software applications.

Windows:
The default installation on any version of Windows is now much easier than it used to be, as
MySQL now comes neatly packaged with an installer. Simply download the installer package,
unzip it anywhere and run the setup.exe file. (https://dev.mysql.com/downloads/installer/ )
The default installer setup.exe will walk you through the trivial process and by default will install
everything under C:\mysql.

Linux:
To install it, simply update the package index on your server and install the default package with
apt-get.
▪ sudo apt-get update
▪ sudo apt-get install mysql-server
Note : Here we use linux as an OS

List of HandFul MYSQL commands:


$ sudo apt-get install mysql-server; Mysql-server installation

$ mysql -u root -p; For login

$ SHOW DATABASES; Show list of databases

$ CREATE DATABASE database name; Create a database

$ DROP DATABASE database name; Delete a database

$ USE database name; for selecting the database

$ SHOW tables; for showing table in database

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
$ CREATE TABLE potluck (id INT NOT Create a table
NULL PRIMARY KEY
AUTO_INCREMENT, name
VARCHAR(20),food
VARCHAR(30),confirmed
CHAR(1),signup_date DATE);

$ DESCRIBE potluck; We can remind ourselves about the table’s


organization with this command

$ INSERT INTO `potluck` Insert values into table


(`id`,`name`,`food`,`confirmed`,`signup_date`)
VALUES (NULL, "John", "Casserole","Y",
'2012-04-11');

$ SELECT * FROM potluck; Viewing the content of table

$ UPDATE `potluck` SET `confirmed` = 'Y' Updating the Existing table


WHERE `potluck`.`name` ='Sandy';

$ ALTER TABLE potluck ADD email Adding a column to table


VARCHAR(40);

$ ALTER TABLE potluck ADD email Adding a column after a specific column
VARCHAR(40) AFTER name;

$ ALTER TABLE potluck DROP email; Dropping a column

$ DELETE from [table_name] where [column For deleting a row


name]=[field text];

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
12. WEB APPLICATION ARCHITECTURE 2

13. Web Browser


The most popular web browsers that are used today are Mozilla Firefox, Google Chrome, Microsoft
Internet Explorer, Apple Safari and the Opera browser. These browsers are free and available for
download and use. Web browsers allow users to view resources that are stored on a server. For

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
example, if you were to visit www.google.com, you are actually viewing a file that is displayed
using the web browser. This file is drafted using the hypertext markup language, or HTML for
short. These files, or web pages as they're commonly known, are pulled from the web server and
then translated by the web browser for the user to view. If you don't have a web browser and
attempt to view the HTML file, you will see numerous amounts of code lines that may not make
sense to the average user. The browser will translate those code lines that makes it easily readable
for the user.

14. Setup for Nginx as Load Balancer


Note : Web Application Architecture 1 give an clear idea for installing and configuring Nginx as
Load Balancer. Refer Web Application Architecture 1.

15. JBOSS
JBoss is a application server, is the most widely used Open Source application server on the market.
The highly flexible and easy-to-use server architecture has made JBoss the ideal choice for users
just starting out with J2EE, as well as senior architects looking for a customizable middleware
platform. The server binary and source code distributions are available from the SourceForge
repository. (http://sourceforge.net/projects/jboss). The ready availability of the source code allows
you to debug the server, learn its inner workings and create customized versions for your personal
or business use.
This chapter is a step-by-step tutorial that will show you how to install and configure JBoss 4.0.
Specifically, you will learn how to:
• Obtain updated binaries from the JBoss SourceForge project site
• Install the binary
• Test the installation
You will also learn about:
• The installation directory structure
• Key configuration files an administrator may want to use to customize the JBoss installation
• Obtaining the source code for the 4.0 release from the SourceForge CVS repository
• Building the server distribution.

Getting the Binary Files


The most recent release of JBoss is available from the SourceForge JBoss project files page,
http://sourceforge.net/projects/jboss. You will also find previous releases as well as beta and release
candidate versions of upcoming releases.

Prerequisites
Before installing and running the server, check your system to make sure you have a working JDK
1.4+ installation. The simplest way to do this is to execute the java -version command to ensure that
the java executable is in your path, and that you are using Version 1.4 or higher. For example,
running this command with a 1.4.1 JDK would produce version number like the following.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
[tmp]$ java -version
java version "1.4.2_05"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_05-b04)
Java HotSpot(TM) Client VM (build 1.4.2_05-b04, mixed mode)

Installing the Binary Package


After you have the binary archive you want to install, use the JDK jar tool (or any other ZIP
extraction tool) to extract the jboss-4.0.1.zip archive contents into a location of your choice. The
jboss-4.0.1.tgz archive is a gzipped tar file that requires a gnutar compatible tar which can handle
the long path names in the archive. The default tar binaries on Solaris and OS X do not currently
support the long path names. The extraction process will create a jboss-4.0.1 directory. The
following section explores the contents of this directory.
Directory Structure

The Default Server Configuration File Set


The JBOSS_DIST/server directory contains one or more configuration file sets. The default JBoss
configuration file set is located in the JBOSS_DIST/server/default directory. JBoss allows you to
add more than one configuration set so a server can easily be run using alternate configurations.
Creating a new configuration file set typically starts with copying the default file set into a new
directory name and then modifying the configuration files as desired.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
Basic Installation Testing
Once you have installed the JBoss distribution, it is wise to perform a simple startup test to validate
that there are no major problems with your Java VM/operating system combination. To test your
installation, move to the JBOSS_DIST/bin directory and execute the run.bat or run.sh script as
appropriate for your operating system.
JBoss Bootstrap Environment :
JBOSS_HOME: /tmp/jboss-4.0.1
JAVA: /System/Library/Frameworks/JavaVM.framework/Home//bin/java
JAVA_OPTS: -server -Xms128m -Xmx128m -Dprogram.name=run.sh
CLASSPATH: tmp/jboss-
4.0.1/bin/run.jar:/System/Library/Frameworks/JavaVM.framework/Home//lib/tools.ja
r
[bin]$ sh run.sh

16. RabbitMQ
RabbitMQ is open source message broker software (sometimes called message-oriented
middleware) that implements the Advanced Message Queuing Protocol (AMQP). The RabbitMQ
server is written in the Erlang programming language and is built on the Open Telecom Platform
framework for clustering and failover.
Note :For RabbitMQ installation guide follow the given link :
https://www.rabbitmq.com/configure.html
Note : For RabbitMQ code examples follow the given link:
https://www.rabbitmq.com/getstarted.html
Below example gives an idea about RabbitMQ as a middleware

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
17. Memchached
Memcached is Free & open source, high-performance, distributed memory object caching system,
generic in nature, but intended for use in speeding up dynamic web applications by alleviating
database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects)
from results of database calls, API calls, or page rendering.
Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of
development, and solves many problems facing large data caches. Its API is available for most
popular languages.

Installing Memcached on Ubuntu


To install Memcached on Ubuntu, go to terminal and type the following commands
$ sudo apt-get update
$ sudo apt-get install memcached

Confirming Memcached Installation


To check if Memcached is presently running or not, run the command given below −
$ ps aux | grep memcached

This command should show that Memcached is running on the default port 11211.

To run Memcached server on a different port, run the command given below
$ memcached -p 11111 -U 11111 -u user -d

It should start the server and listen on TCP port 11111 and UDP port 11111 as a daemon process.

This command is explained below −

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
• -p is for TCP port number
• -U is for UDP port number
• -u is for user name
• -d runs memcached as daemon process

You can run multiple instances of Memcached server through a single installation.

What do we use Memcached for?


• Caching
o Datastore query result
o Use Authentication token and session data
o API calls or other computational data
• Sharing data cross App Instances

Why do we need Memcached?


✓ Improve application performance
✓ Reduce application cost

Application Memcached DB

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
18. WEB APPLICATION ARCHITECTURE 3

This architecture describes an approach to designing heavyweight web application for robust,
concurrent with fault-tolerance and distributed software structure. An app is robust when it can
work consistently with inconsistent data. For example: a maps application is robust when it can
parse addresses in various formats with various misspellings and return a useful location.

This web application architecture contains load balancing, static content handler, dynamic content
handler(NodeJS), Elastic search (For Indexing), Memcached,NoSQL Database (MongoDB).
Load Balancer:
Note: Web Application Architecture 1 give a clear idea for installing and configuring Nginx as
Load Balancer. Refer Web Application Architecture 1.

Apache HTTP Server:


Note: Web Application Architecture 1 give an idea for installing and configuring Apache HTTP
server for handling static content of the application. Refer Web Application Architecture 1 for more
details on Apache HTTP server.

19. NodeJS Server:


Node.js is a JavaScript runtime built on Chrome's V8 JavaScript engine. Node.js uses an event-
driven, non-blocking I/O model that makes it lightweight and efficient.
➢ NodeJs is nothing but javascript running on server.
➢ Use to build powerful, fast & scalable application.
➢ Node.js uses an event-driven, non-blocking I/O model.
Visualpath Training & Consulting.
Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
➢ Node.js uses a single threaded model with event looping.
➢ Node.js applications never buffer any data. These applications simply output the data in
chunks.

Node.js Runtime
The source code written in source file will be normal javascript code only. The Node.js interpreter
will be used to interpret and execute your javascript code.
Node.js distribution comes as a binary installable for SunOS , Linux, Mac OS X, and Windows
operating systems with the 32-bit (386) and 64-bit (amd64) x86 processor architectures.
Following section guides you on how to install Node.js binary distribution on various OS.

Download Node.js archive


Download latest version of Node.js installable archive file from( https://nodejs.org/en/ ) At the time
of writing this tutorial, following are the versions available on different OS.

OS Archive name

Windows node-v6.11.0-x64.msi

Linux node-v6.11.0-linux-x86.tar.gz

Mac node-v6.11.0-darwin-x86.tar.gz

SunOS node-v6.11.0-sunos-x86.tar.gz

Add /usr/local/nodejs/bin to the PATH environment variable.


OS Output

Linux export PATH=$PATH:/usr/local/nodejs/bin

Mac export PATH=$PATH:/usr/local/nodejs/bin

FreeBSD export PATH=$PATH:/usr/local/nodejs/bin

Note: In Linux, we can have installation directly from linux shell by using apt package manager.
following commands
sudo apt-get update
sudo apt-get install nodejs

If the package in the repositories suits your needs, this is all that you need to do to get set up with
Node.js. In most cases, you'll also want to also install npm, which is the Node.js package manager.
You can do this by typing:

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
sudo apt-get install npm

Verify installation: Executing a File


Open terminal in linux and command prompt in Windows and Use following command
$ node
> console.log('Hello World!');
Hello World!

•Create a js file named app.js on your machine (Windows or Linux) having the following code.
/* Hello, World! program in node.js */
console.log("Hello, World!")

Now execute app.js file using Node.js interpreter to see the result:
$ node app.js

If everything is fine with your installation, this should produce the following result:
Hello, World!

Creating Node.js Application


In above example we have created a sample application to run “Hello World !” In terminal ,Now
printing hello world to a terminal isn't all that exciting. Let's take the next step and write a program
that responds to hello world via http. We'll call the file 'hello_http.js' and put the following code
into it:

var http = require('http');

var server = http.createServer(function(req, res) {


res.writeHead(200);

// Send the response body as "Hello World"

res.end('Hello World');
});
server.listen(8081);

// Console will print the message


console.log('Server running at http://127.0.0.1:8081/');

Now let's run this program from the terminal by typing:


$ node hello_http.js

We can hit the browser with http://127.0.0.1:8081/

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
20. Elasticsearch
Elasticsearch is a real-time distributed and open source full-text search and analytics engine.
Elasticsearch is able to achieve fast search responses because, instead of searching the text directly,
it searches an index instead. Elasticsearch is developed in java.
Elasticsearch uses JSON objects as responses, which makes it possible to invoke the Elasticsearch
server with a large number of different programming languages.

Elasticsearch Installation
The steps for installation of Elasticsearch are as follows:

Step 1 − Check and Verify the minimum version of your java is installed your computer, it should
be java 7 or more updated version. You can check by doing the following:
Note −Please make sure, JAVA_HOME set, please set it in environment variables to “C:\Program
Files\Java\jre1.8.0_31” or the location where you installed java.

In Windows Operating System (OS) (using command prompt):


$ java -version
In UNIX OS (Using Terminal)

$ echo $JAVA_HOME

Step 2 − Download latest version of Elasticsearch from


https://www.elastic.co/downloads/elasticsearch
For windows OS download ZIP file.
For UNIX OS download TAR file.
For Debian OS download DEB file.
For Red Hat and other Linux distributions download RPN file.
APT and Yum utilities can also be used to install Elasticsearch in many Linux distributions.

Step 3 − Installation process for Elasticsearch is very easy and described below for different OS −
• Windows OS − Unzip the zip package and the Elasticsearch is installed.
• UNIX OS − Extract tar file in any location and the Elasticsearch is installed.

$ tar –xvf elasticsearch-5.4.1.tar.gz

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
Using APT utility for Linux OS −
Download and install the Public Signing Key −
$ wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key
add -

Save the repository definition:


$ echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" |
sudo tee -a /etc /apt/sources.list.d/elasticsearch-2.x.list

Run update:
$ sudo apt-get update

Now you can install by using the following command


$ sudo apt-get install elasticsearch

Step 4 − Go to the Elasticsearch home directory and inside the bin folder. Run the elasticsearch.bat
file in case of windows or you can do the same using command prompt and through terminal in case
of UNIX run Elasticsearch file.
In Windows −
> cd elasticsearch-2.1.0/bin
> elasticsearch

In Linux −
$ cd elasticsearch-2.1.0/bin
$ ./elasticsearch

Step 5 − Default port for Elasticsearch web interface is 9200 or you can change it by changing
http.port inside elasticsearch.yml file present in bin directory. You can check if the server is up and
running by browsing http://localhost:9200. It will return a JSON object, which contains the
information about the installed Elasticsearch in the following way :

{
"name" : "Brain-Child",
"cluster_name" : "elasticsearch", "version" : {
"number" : "2.1.0",
"build_hash" : "72cd1f1a3eee09505e036106146dc1949dc5dc87",
"build_timestamp" : "2015-11-18T22:40:03Z",
"build_snapshot" : false,
"lucene_version" : "5.3.1"
},
"tagline" : "You Know, for Search"

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
}

Note: Memcached description and installation are given in web application architecture-2 .please
refer web application architecture-2 for more details.

21.MongoDB
MongoDB is an open-source document-oriented database. MongoDB is one of highly used NoSQL
database. MongoDB is written in C++.
All the modern applications require big data, fast features development, flexible deployment and the
older database systems not enough competent, so the MongoDB is designed to fulfil the
requirement.

MongoDB Supported Feature:


• Support ad hoc queries --In MongoDB, you can search by field, range query and it also
supports regular expression searches.
• Indexing -- You can index any field in a document.
• Replication -- MongoDB supports Master Slave replication.
• Duplication of data --MongoDB can run over multiple servers. The data is duplicated to
keep the system up and also keep its running condition in case of hardware failure.
• Schema less
• Scalability
• Performance
• High Availability
• Scaling from single server deployments to large, complex multi-site architectures.

Install MongoDB On Windows


To install MongoDB on Windows, first download the latest release of MongoDB from
https://www.mongodb.org/downloads. Make sure you get correct version of MongoDB depending
upon your Windows version.
32-bit versions of MongoDB only support databases smaller than 2GB and suitable only for testing
and evaluation purposes.

Now extract your downloaded file to c:\ drive or any other location.
Make sure the name of the extracted folder is mongodb-win32-i386-[version] or mongodb-win32-
x86_64-[version]. Here [version] is the version of MongoDB download.

Next, open the command prompt and run the following command.
C:\> move mongodb-win64-* mongodb
1 dir(s) moved.
C:\>

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
In case you have extracted the MongoDB at different location, then go to that path by using
command cd FOLDER/DIR and now run the above given process.
MongoDB requires a data folder to store its files. The default location for the MongoDB data
directory is c:\data\db. So, you need to create this folder using the Command Prompt.

Execute the following command sequence.


C:\>md data
C:\md data\db

If you have to install the MongoDB at a different location, then you need to specify an alternate
path for \data\db by setting the path dbpath in mongod.exe. For the same, issue the following
commands.
In the command prompt, navigate to the bin directory present in the MongoDB installation folder.

Suppose my installation folder is D:\Software\mongodb


C:\Users\XYZ\ABC>d:
D:\>cd Software
D:\Software>cd mongodb
D:\Software\mongodb>cd bin
D:\Software\mongodb\bin>mongod.exe --dbpath "d:\Software\mongodb\data"

The result will show waiting for connections message on the console output, which indicates that
the mongod.exe process is running successfully.
Run MongoDB:
Now to run the MongoDB, you need to open another command prompt and execute the following
command.
D:\Software\mongodb\bin>mongo.exe
MongoDB shell version: 2.4.6
connecting to: test
>db.test.save( { a: 1 } )
>db.test.find()
{ "_id" : ObjectId(5879b0f65a56a454), "a" : 1 }
>

This will show that MongoDB is installed and run successfully. Next time when you run
MongoDB, you need to issue only commands.

D:\Software\mongodb\bin>mongod.exe --dbpath "d:\Software\mongodb\data"


D:\Software\mongodb\bin>mongo.exe

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
Install MongoDB on Ubuntu
Import the public key used by the package management system. Run the following command to
import the MongoDB public GPG key.

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Create a list file for MongoDB ,create a /etc/apt/sources.list.d/mongodb.list file using the following
command.
echo 'deb http://downloads-distro.mongodb.org/repo/ubuntu-upstart dist 10gen'
| sudo tee /etc/apt/sources.list.d/mongodb.list

Now issue the following command to update the repository −


sudo apt-get update

Install Mongodb packages.


You can install either the latest stable version of MongoDB or a specific version of MongoDB.
Install the latest stable version of MongoDB.

Issue the following command:


sudo apt-get install -y mongodb-org

Next install the MongoDB by using the following command


To install a specific release, you must specify each component package individually along with the
version number, as in the following example:
apt-get install mongodb-10gen =3.4.5

In the above installation, 3.4.5 is currently released MongoDB version. Make sure to install the
latest version always. Now MongoDB is installed successfully.
Start MongoDB
sudo service mongodb start

Stop MongoDB
sudo service mongodb stop

Restart MongoDB
sudo service mongodb restart

To use MongoDB run the following command.


Mongo This will connect you to running MongoDB instance.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.
Remove Packages
Remove any MongoDB packages that you had previously installed.
sudo apt-get purge mongodb-org*

Remove Data Directories


Remove MongoDB databases and log files.

sudo rm -r /var/log/mongodb
sudo rm -r /var/lib/mongodb

Technologies Use for an Web Application


Front End (in the browser of the user):
1) HTML for the structure of a single web page
2) CSS for the design of elements of the single web page, often as a repository for many web pages
to keep consistency
3) Native Javascript or libraries like jQuery. AJAX that allow interaction with the user and the
backend system while staying on the same page.
4) Other special technologies e.g. Flash Movie Addins or such, most often replaced by HTML 5.

Backend (on the server of the host of the web page):


1) Operating system (e.g. Linux)
2) Web application Server (e.g. Apache)
3) Database, e.g. MySql ,MongoDB or other
4) PHP,Java,python and nodeJs and other languages to run queries on the database etc.

Summary:
➢ Any Architectural design include Many point such as what (conceptual) parts does our app
consist of? How do the different parts communicate with each other? How do they depend
on each other?
➢ A well-defined Architecture consist of Many components which communicate hand to hand
with each other with higher accuracy and less fault tolerance.
➢ A web application architecture consist of many services such as load balancer, Message
broker(ActiveMQ/rabbitMQ), Elasticsearch, web server(Tomcat),Application
server(JBOSS),Node JS and different high level programming language such as Java, PHP,
python and Javascript etc.
➢ Above three different web application architectural design are given to understood the real
time web application design.

Conclusion:
The goal of Chapter was to provide a understanding of architectural design with necessary
background information for Web-based applications. Every architectural design will be different
based on the requirement and facilities(Technologies) used. Nowadays growing web-based
applications thus requires both scalable architectures and appropriate concepts for concurrent
programming.

Visualpath Training & Consulting.


Flat no: 205, Nilgiri Block,Aditya Enclave, Ameerpet, Hyderabad, Phone No: - +91-970 445 5959, 961 824 5689 E-
Mail ID : online.visualpath@gmail.com, Website : www.visualpath.in.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy