Module 2
Module 2
CCA2002
Module 2
⚫ Cloud Services: Web Service Architecture – Web Service APIs –
Web service Authentication - Web service authentication methods
- Technologies and the processes required when deploying web
services; Deploying a web service from inside and outside a cloud
architecture, advantages and disadvantages.
2
Web Service Architecture
⚫ Web service architecture is a structured approach to designing
and building web services, which are systems that allow
applications to communicate over a network using standard
protocols like HTTP.
3
Core components of Web Service Architecture
⚫ 1. Service Provider
The service provider hosts the web service and provides the functionality to be
accessed remotely. It defines the service description and makes the service
available to clients.
Key role: Provides the actual service, including resources or business logic.
6
Web Service
⚫ A web service is a software system that enables machine-to-
machine communication over a network.
7
Key features of Web Service
8
Key features of Web Service
9
Types of Web Service
1. SOAP (Simple Object Access Protocol)
• A protocol-based web service that uses XML for communication.
SOAP is highly structured and supports standards like security,
transactions, and reliable messaging.
• Advantages:
• Stronger security standards (e.g.,WS-Security)
• Reliability and transaction support
• Disadvantages:
• Heavier and more complex
• Slower due to extensive XML processing
10
Types of Web Service
2. REST (Representational State Transfer)
1. REST is an architectural style, not a protocol, and it typically uses
HTTP methods (GET, POST, PUT, DELETE) to operate on resources
represented by URLs.
2. Advantages:
1. Lightweight and easy to implement
2. Scalability and performance
3. Disadvantages:
1. Stateless nature may require additional logic for managing sessions
2. Less formal structure for contracts compared to SOAP
11
Web Service Authentication
Web service authentication refers to the process of verifying the
identity of users or systems before they can access a web service.
12
Web Service Authentication Methods
⚫ 1. HTTP Basic Authentication
How it works:The client sends the username and password encoded
in Base64 as part of the HTTP request header (using the
"Authorization" header).
Example:
⚫ Advantages:
• Simple to implement.
⚫ Disadvantages:
• Username and password are transmitted with every request, even though encoded,
not encrypted.
• Should always be used over HTTPS to prevent credentials from being exposed.
13
Web Service Authentication Methods
⚫ OAuth (Open Authorization)
• How it works: OAuth is a token-based authentication protocol that
allows third-party services to access resources without exposing user
credentials. OAuth 2.0 is the most widely used version.
• The user authenticates with an authorization server, which issues an
access token.
• The client includes the access token in the Authorization header with
every request to the web service.
14
Web Service Authentication Methods
Advantages:
• Secure and scalable.
• Does not require sharing credentials with the client.
• Can grant limited access (scope-based) to services.
Disadvantages:
• More complex to implement compared to Basic or API key
authentication.
15
Web Service Authentication Methods
API Key Authentication
How it works:The service provider issues an API key to the client,
which must be included in the request header or URL query
parameters.
• Advantages:
• Simple to implement.
16
Web Service Authentication Methods
• Disadvantages:
• Less secure than other methods because API keys can be easily
shared or leaked.
17
Web Service Authentication Methods
⚫ SAML (Security Assertion Markup Language)
• How it works: SAML is an XML-based standard used for exchanging
authentication and authorization data between a service provider and an
identity provider (typically in Single Sign-On (SSO) scenarios).
• The service provider trusts the identity provider to authenticate users.
• Once authenticated, the identity provider sends an assertion to the service
provider.
• Advantages:
• Suitable for enterprise-level services.
• Can be used for SSO.
• Disadvantages:
• Heavy XML-based format.
• More complex to implement than OAuth or JWT.
18
Web Service Authentication Methods
⚫ Digest Authentication
• How it works: Digest authentication is more secure than basic
authentication. Instead of sending plain credentials, it sends a hashed
version of the username and password.
• Advantages:
• Credentials are not sent in plain text.
• Disadvantages:
• More complex to implement than basic authentication.
• Still vulnerable to man-in-the-middle attacks if not used over HTTPS.
19
Key Technologies for Deploying Web Services
⚫ 1.Web Server
• Examples: Apache HTTP Server, Nginx, Microsoft IIS
• Purpose: A web server handles HTTP requests from clients and
routes them to the appropriate web service.
• Role: Serves as the entry point for web service requests and can be
configured to handle SSL (HTTPS), load balancing, and redirection.
⚫ 2. Application Server
• Examples: Tomcat, Jetty, JBoss,WebSphere
• Purpose: Hosts the web service’s business logic. An application
server is where your web service runs.
• Role: Executes code, manages the lifecycle of service requests, and
communicates with databases or other services.
20
Key Technologies for Deploying Web Services
⚫ 3. Database
• Examples: MySQL, PostgreSQL, MongoDB, Redis
• Purpose: Stores and manages the data consumed or produced by the web
service.
• Role: Ensures data persistence, supports queries, and allows for efficient
storage and retrieval of information.
⚫ 4. API Gateway
• Examples: Kong, AWS API Gateway, NGINX, Apigee
• Purpose: An API gateway manages API requests from clients, often acting
as a reverse proxy.
• Role: Provides rate limiting, security (authentication, authorization),
routing, and caching. It also serves as a central entry point for API calls.
21
Key Technologies for Deploying Web Services
⚫ 5. Containerization Platforms
• Examples: Docker, Kubernetes
• Purpose: Containerization allows you to package your web service along
with its dependencies, ensuring it runs consistently across environments.
• Role: Containers make it easy to deploy web services to various
environments (local, testing, production) and offer scalability.
• Kubernetes is often used to orchestrate containerized applications, manage
scaling, and handle load balancing.
⚫ 6. Load Balancer
• Examples: HAProxy, AWS Elastic Load Balancer (ELB), NGINX
• Purpose: Distributes incoming requests across multiple servers or
instances of a web service.
• Role: Ensures high availability, fault tolerance, and load distribution to
22 improve performance and handle traffic spikes.
Key Technologies for Deploying Web Services
⚫ 7. CI/CD Pipeline Tools
• Examples: Jenkins, GitLab CI, CircleCI,Travis CI
• Purpose: Continuous Integration and Continuous Deployment (CI/CD)
pipelines automate the process of building, testing, and deploying web
services.
• Role: Ensures that changes made by developers are integrated and
deployed quickly, with minimal manual intervention.
⚫ 8. Cloud Platforms
• Examples: AWS (Amazon Web Services), Microsoft Azure, Google Cloud
Platform (GCP)
• Purpose: Cloud platforms provide infrastructure as a service (IaaS) and
platform as a service (PaaS) for deploying web services.
• Role: Cloud services can host your web service, manage scaling, and
handle networking and security.They also offer managed databases, load
balancers, and serverless architectures.
23
Key Technologies for Deploying Web Services
⚫ 9. Security Technologies
• Examples: OAuth, JWT, SSL/TLS, Firewall, IAM (Identity and Access
Management)
• Purpose: Secures the web service from unauthorized access and attacks.
• Role: Implements authentication, authorization, encryption, and access
control measures to protect sensitive data and ensure secure
communication.
⚫ 2.Testing
• Technology:Testing frameworks (JUnit, Mocha, Postman), CI/CD
Pipeline Tools
• Process:
• Unit Testing:Testing individual components of the web service to ensure they
behave as expected.
• Integration Testing: Ensures that different parts of the web service work
together.
• API Testing:Validates the input/output and behavior of the web service’s API
25 endpoints.
Key Processes Involved in Deploying Web Services:
⚫ 3. Containerization & Packaging
• Technology: Docker, Docker Compose, Kubernetes (for
orchestration)
• Process:
• Packaging the application into containers to isolate dependencies.
• Using container orchestration tools like Kubernetes to manage scaling,
load balancing, and fault tolerance.
⚫ 4. Continuous Integration (CI)
• Technology: Jenkins, GitLab CI, CircleCI
• Process:
• Automating the build process to compile the web service.
• Running automated tests on every code change to ensure the stability
of the service.
26
Key Processes Involved in Deploying Web Services:
⚫ 5. Continuous Deployment (CD)
• Technology: Jenkins, AWS CodeDeploy, GitLab CI
• Process:
• Automatically deploying the web service to a production or staging
environment after it passes all tests.
• Managing blue/green or rolling deployments to avoid downtime.
⚫ 6. Deployment to Cloud
• Technology: AWS, Microsoft Azure, Google Cloud, DigitalOcean
• Process:
• Setting up infrastructure (e.g., virtual machines, databases, and
networking) in the cloud.
• Deploying the web service to cloud platforms or using PaaS (Platform
as a Service) like AWS Lambda (for serverless architecture) or Azure
App Services.
27
Key Processes Involved in Deploying Web Services:
⚫ 7. Load Balancing and Scaling
• Technology: HAProxy, AWS ELB, Kubernetes
• Process:
• Configuring load balancers to distribute incoming traffic across multiple
instances of the web service.
• Configuring auto-scaling to add/remove instances based on traffic and
resource usage.
⚫ 8. Monitoring and Logging
• Technology: Prometheus, Grafana, ELK Stack, Datadog
• Process:
• Setting up performance metrics monitoring for server and service health.
• Implementing logging for troubleshooting and debugging issues in
production.
• Configuring alert systems for failures or anomalies in service behavior.
28
Key Processes Involved in Deploying Web Services:
⚫ 9. Security
• Technology: SSL/TLS, OAuth2, Firewalls, IAM (Identity Access
Management)
• Process:
• Implementing SSL/TLS for encrypted communication.
• Configuring OAuth, JWT, or API key-based authentication.
• Setting up firewalls, secure access policies, and role-based access
control (RBAC).
⚫ 10. Backup and Disaster Recovery
• Technology: Cloud-native backup solutions, Database replication
tools
• Process:
• Configuring automated backups of databases and critical services.
• Planning and testing disaster recovery strategies for system failures.
29
Summary of the Web Service Deployment Process:
• Development:Write and manage the code for the web service.
• Testing: Run tests to ensure that the service is functional and error-free.
• Containerization: Package the service in a container for consistent
deployment.
• CI/CD Pipeline: Automate building, testing, and deploying the service.
• Deployment: Deploy to a cloud or on-premises infrastructure.
• Load Balancing and Scaling: Ensure the service can handle traffic and
scale as needed.
• Security: Implement robust security measures for authentication,
encryption, and access control.
• Monitoring: Continuously monitor the service’s health and performance.
• Backup & Recovery: Prepare for disaster recovery and ensure data
integrity.
30
Deploying a Web Service Inside a Cloud Architecture
Cloud architecture refers to deploying and managing services on cloud
infrastructure such as AWS, Microsoft Azure, Google Cloud Platform (GCP), or
others. Cloud environments provide on-demand resources, flexibility, scalability,
and automation, making deployment faster and easier.
⚫ a. Infrastructure Setup
• Infrastructure as a Service (IaaS): You can create virtual machines (VMs) or
containers for hosting your web service.
• Platform as a Service (PaaS): Platforms like AWS Elastic Beanstalk, Azure
App Services, or Google App Engine handle the infrastructure management,
allowing developers to focus solely on code.
• Serverless Architecture: You can deploy services without worrying about
server management using serverless computing platforms like AWS Lambda,
Azure Functions, or GCP Cloud Functions.
31
Deploying a Web Service Inside a Cloud Architecture
⚫ b. Deployment Process
1. Development:
1. Develop your web service using programming languages like Java, Python,
Node.js, or others.
2. Containerization:
1. Use Docker to containerize the web service for a consistent environment
across development, testing, and production.
2. Use Kubernetes or managed services like AWS EKS (Elastic Kubernetes
Service), GCP GKE (Google Kubernetes Engine) to orchestrate the containers.
3. Infrastructure as Code (IaC):
1. Use IaC tools like Terraform, AWS CloudFormation, or Azure Resource
Manager (ARM) templates to define and provision infrastructure
automatically.
2. Automates the deployment of servers, networking, databases, and other
services.
32
Deploying a Web Service Inside a Cloud Architecture
4. CI/CD Pipeline:
• Implement CI/CD pipelines using Jenkins, GitLab CI, or AWS CodePipeline to
automate testing and deployment.
5. Security Configuration:
• Set up IAM (Identity and Access Management) for role-based access.
• Configure SSL/TLS certificates for secure communication using cloud services like
AWS Certificate Manager or Let’s Encrypt.
• Implement OAuth, JWT, or API keys for securing APIs.
• Deploy a Load Balancer (e.g., AWS Elastic Load Balancer, Azure Load Balancer, GCP
Load Balancer) to distribute traffic across instances
33
Deploying a Web Service Inside a Cloud Architecture
7. Database and Storage:
• Use managed databases like Amazon RDS, Azure SQL Database, or Google
Cloud SQL for relational data.
• Use S3 (AWS), Blob Storage (Azure), or Google Cloud Storage for object
storage.
34
Deploying a Web Service Inside a Cloud Architecture
⚫ Advantages of Cloud Deployment:
35
Deploying a Web Service Inside a Cloud Architecture
⚫ Disadvantages:
36
Deploying a Web Service Outside a Cloud Architecture
⚫ Deploying a web service outside the cloud typically involves using traditional,
on-premises infrastructure or third-party hosting services. In this case, you are
responsible for managing the entire hardware and software stack, which can offer
greater control but requires more manual management.
⚫ a. Infrastructure Setup
• Physical Servers: Host your service on physical machines located in a data
center or within your organization.
• Virtual Machines (VMs): Use a hypervisor (e.g., VMware, Hyper-V, KVM) to
run virtual machines on physical hardware.
• Managed Hosting: Services like GoDaddy, DigitalOcean provide virtual or
dedicated servers but don’t offer the extensive automation of cloud providers.
37
Deploying a Web Service Outside a Cloud Architecture
• Load Balancing:
• Set up load balancing using HAProxy, Nginx, or hardware load balancers.
• Networking:
• Configure firewalls, VPNs, and DNS settings manually.
• Security Configuration:
• Manage your own SSL/TLS certificates, set up firewalls, and configure IP
whitelisting.
3•8Use LDAP or Active Directory for authentication.
Deploying a Web Service Outside a Cloud Architecture
• Monitoring and Logging:
• Set up your own monitoring tools like Nagios, Zabbix, or Prometheus
to monitor the health and performance of the service.
39
Advantages of Non-Cloud Deployment:
• Full Control:You have complete control over hardware, networking, and
configurations.
40
Disadvantages of Non-Cloud Deployment:
• Cost: Higher upfront capital expenditure (CAPEX) for hardware, with ongoing
costs for maintenance and upgrades.
• Elasticity: Unlike the cloud, it’s difficult to scale resources up and down based
41
on fluctuating traffic.
Comparison of Cloud vs Non-Cloud Deployment:
42
Service-Oriented Architecture (SOA):
• Service-Oriented Architecture (SOA) is a design pattern where
software components, called services, are made available to other
components over a network.
• These services are reusable, loosely coupled, and can interact with each
other using standard communication protocols.
43
Characteristics of SOA
• Loose Coupling: Services in SOA are designed to be independent. The
implementation of each service does not depend on the implementation of other
services, allowing for flexibility in changes and upgrades.
• Abstraction: The inner workings of a service are hidden from the consumer.
Users interact with services through well-defined interfaces without knowing how
the service is implemented.
44
Characteristics of SOA
• Discoverability: Services are published in a registry where they can be
found and invoked by service consumers. This promotes the reuse of services
across different domains.
Challenges:
•Scalability and Flexibility Issues: The synchronous nature and tight
coupling made it difficult to scale.
•Characteristics:
• Standardization and Loose Coupling: Contemporary SOA emphasizes
standardized service contracts, protocols (e.g., REST, GraphQL), and data
formats (e.g., JSON) to achieve loose coupling and interoperability.
•Characteristics:
• Two-Tier Architecture: It consists of two main components: the client
(frontend) and the server (backend). Clients send requests to the server, which
processes them and returns responses.
• Tight Coupling: The client and server are often tightly coupled, meaning that
changes to one can significantly impact the other.
• Synchronous Communication: Requests are usually processed
synchronously, meaning the client waits for a response before continuing its
workflow.
• Centralized Server: The server acts as a central point of control, handling
most of the business logic and data processing.
• Limited Scalability: As the number of clients grows, the central server can
become a bottleneck, limiting scalability.
Client-Server Architecture
Use Cases:
Use Cases: