Core Internet Concepts
The internet functions as a network of networks, serving as the parent set for all network types. The Internet represents the world's largest internetwork—a specific implementation within the broader internet concept. Computers connected to the Internet are commonly referred to as hosts.
The World Wide Web (WWW) is not a specialized computer network but rather a massive, online information repository. It enables convenient navigation between sites through hyperlinking, providing distributed services. The WWW operates as a distributed hypermedia system extending hypertext functionality, built on a client-server architecture.
URLs (Uniform Resource Locators) serve as the addressing mechanism for locating documents across the WWW, providing each resource with a unique identifier within the internet.
HTTP (HyperText Transfer Protocol) addresses the challenge of implementing network communication for web document delivery. It establishes strict protocols governing interactions between web client applications (primarily browsers) and web server programs. HTTP functions as an application-layer protocol utilizing TCP for reliable transport. The WWW specifically relies on HTTP (port 80/TCP) and HTTPS (port 443/TCP), though the internet supports numerous other application systems including FTP and SMTP.
HTML (HyperText Markup Language) defines standards and specifications for marking up web page content. These markup symbols instruct browsers on rendering page elements. HTML files are plain text documents that become web pages when saved with .html or .htm extensions.
Browser Request Workflow
A complete HTTP transaction involves several stages:
- DNS Resolution: Domain names are resolved using the DNS protocol
- Connection Establishment: TCP three-way handshake occurs
- HTTP Request Initiation: Browser sends an HTTP request after TCP connection is established
- HTTP Response: Server responds, returning the response to the browser
- Response Parsing: Browser parses the response and requests additional resources (CSS, JavaScript)
- Page Rendering: Browser rendering engine displays the page
- Connection Termination: TCP four-way handshake closes the connection
HTTP Communication Model
HTTP is an application-layer protocol designed for distributed, collaborative hypermedia information systems. It serves as the foundational communication mechanism for the World Wide Web. The protocol's original design enabled knowledge sharing across distances through interconnected documents.
Web Technologies Overview
Frontend Technologies
HTML structures web page content using markup tags. CSS (Cascading Style Sheets) controls visual presentation—fonts, colors, layouts—typically stored in external .css files for consistent styling across multiple pages. JavaScript enables interactive and animated web experiences, though it executes as a static resource from the server's perspective.
MIME Types
MIME (Multipurpose Internet Mail Extensions) identifies file formats for web content transmission. MIME types consist of a type and subtype separated by a slash:
| Type | Subtype Examples | Description |
|---|---|---|
| text | plain, html, css | Text content |
| image | jpeg, png, gif | Image files |
| video | mp4, webm | Video content |
| application | javascript, json | Application data |
Configuration files are located at /etc/mime.types from the mailcap package.
URI Components
URI (Uniform Resource Identifier) encompasses URLs and URNs:
<scheme>://<user>:<password>@<host>:<port>/<path>;<params>?<query>#<frag>
- scheme: Protocol for resource access (http, https, ftp)
- user/password: Authentication credentials when required
- host: Server hostname or IP address
- port: Listening port number
- path: Local resource path on server
- params: Input parameters as name/value pairs
- query: Parameters passed to programs (database queries)
- frag: Client-side resource fragment identifier
Website Traffic Metrics
IP (Independent IP): Unique visitor IP addresses counted once per day. Measures raw visitor count based on remote client IP addresses.
PV (Page View): Total page loads or refreshes. Indicates website popularity by counting actual page visits, proportional to visitor engagement.
UV (Unique Visitor): Single device counted once per day, identified through browser cookies. Represents the number of unique computers accessing the site.
HTTP Transaction Mechanics
Transaction Components
Each HTTP transaction consists of a request and corresponding response.
Web Resources
A single web page typically comprises multiple resources (files), each requiring individual requests. Static files like .html, .txt, .jpg, .js, .css, and .mp3 remain unchanged by the server. Dynamic resources like .php, .jsp, and .asp execute server-side code before returning results.
Connection Strategies
HTTP supports several connection optimization approaches:
- Parallel connections: Multiple TCP connections for concurrent requests
- Persistent connections: Keep-alive reuses TCP connections across multiple transactions
- Pipelining: Sends multiple requests without waiting for each response
- Connection multiplexing: Alternates request/response transmission (experimental)
HTTP Protocol Evolution
HTTP/0.9
Deprecated version accepting only GET requests without version identification. Unable to transmit additional client information.
HTTP/1.0
First protocol version specifying version numbers. Widely adopted, particularly in proxy servers.
HTTP/1.1
Introduced persistent connections as default behavior, eliminating per-request connection overhead. Supports pipelining for concurrent request handling. HTTP/1.1 is the most prevalent version in current deployment.
HTTP/2.0
Based on Google's SPDY protocol, standardized in 2015. Features include binary framing, full request/response multiplexing on single connections, header compression, and server push capabilities.
HTTP/1.0 vs HTTP/1.1 Differences
HTTP/1.1 introduces enhanced caching strategies with entity tags and conditional headers. Bandwidth optimization comes through range requests supporting partial content downloads. Additional status codes (409, 410) provide clearer error messaging. Host headers enable virtual hosting on shared IP addresses. Persistent connections reduce connection overhead through keep-alive behavior.
HTTP/1.x Limitations
Repeated connection establishment introduces latency, particularly problematic on mobile networks. All transmitted data remains unencrypted. Redundant header information consumes bandwidth, especially problematic on constrained connections. Keep-alive connections, while reducing handshake overhead, can strain server resources when holding idle connections for extended periods.
HTTPS Protocol
HTTPS, developed by Netscape in 1994, implements HTTP over SSL/TLS for secure communication. SSL evolved into TLS, with HTTPS officially defined in RFC 2818.
Characteristics:
- Requires CA-issued certificates (typically paid)
- Encrypts all transmitted content through TLS
- Operates on port 443 (port 80 for HTTP)
- Prevents ISP traffic manipulation
- Slight performance overhead compared to HTTP
HTTP Request Lifecycle
Processing steps for each HTTP transaction:
- Accept/reject incoming connections
- Receive and parse client requests
- Process requests and extract resource information
- Access requested resources
- Construct response messages
- Transmit responses
- Log transaction details
Request Processing Models
- Single-process I/O: One process handles requests sequentially
- Multi-process I/O: Multiple processes handle concurrent connections
- Multiplexed I/O: Single process manages multiple connections
- Hybrid model: M processes handle N connections each (M×N capacity)
Request Methods
| Method | Purpose |
|---|---|
| GET | Retrieve resource content |
| HEAD | Retrieve headers only |
| POST | Submit entity data |
| PUT | Upload resources |
| PATCH | Partial resource modification |
| DELETE | Remove resources |
| OPTIONS | Query supported methods |
| CONNECT | Establish tunnel connections |
| TRACE | Debug request paths |
HTTP Headers Reference
Genarel Headers
Apply to both requests and responses: Date, Connection, Via, Cache-Control, MIME-Version, Warning.
Request Headers
Client-supplied information: Accept, Accept-Charset, Accept-Encoding, Except-Language, Client-IP, Host, Referer, User-Agent, Authorization, Cookie.
Response Headers
Server-supplied metadata: Accept-Ranges, Vary, Set-Cookie, WWW-Authenticate, Age, Server.
Entity Headers
Content metadata: ETag, Expires, Last-Modified, Allow, Location, Content-Encoding, Content-Language, Content-Type.
Response Status Codes
1xx: Informational (100-101)
2xx: Success (200-206)
3xx: Redirection (300-307)
4xx: Client Errors (400-415)
5xx: Server Errors (500-505)
Common status codes:
- 200 OK: Request successful
- 301/302: Resource moved permanently/temporarily
- 304 Not Modified: Conditional request with unchanged resource
- 401 Unauthorized: Authentication required
- 403 Forbidden: Access denied
- 404 Not Found: Resource unavailable
- 500 Internal Server Error: Server-side processing failure
- 502 Bad Gateway: Invalid proxy/gateway response
- 503 Service Unavailable: Server overloaded or maintenance
- 504 Gateway Timeout: Upstream server timeout
Apache Web Server
Apache originated at NCSA in the early 1990s, with open-source release in 1995. The name references both "a patchy" (derived from NCSA code) and the Apache Native American tribe known for strategic warfare.
Key Features
- HTTP protocol compliance
- Virtual host support (IP-based, port-based, name-based)
- CGI (Common Gateway Interface) support
- Reverse proxying
- Load balancing
- Path aliases
- Authentication mechanisms (Basic, Digest)
- Extensible module architecture
MPM (Multi-Processing Module) Configurations
Apache supports three MPM modes, selectable at compile time:
Prefork MPM
Pre-spawns multiple idle processes awaiting connections. Each child process handles one request sequentially. Configuration parameters:
StartServers 100
MinSpareServers 50
MaxSpareServers 80
ServerLimit 2560
MaxRequestWorkers 2560
MaxConnectionsPerChild 4000
Advantages: Stability, simplicity Disadvantages: Higher memory consumption, lower concurrency
Worker MPM
Combines multiple processes with thread-based handling. Each process spawns multiple threads, with threads handling individual requests.
ServerLimit 16
StartServers 10
MaxRequestWorkers 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
Advantages: Lower memory usage, higher concurrency Disadvantages: Threads held by keep-alive connections may become unavailable
Event MPM
Event-driven variant of worker model. Dedicated management threads monitor keep-alive connections, releasing idle threads for active requests. Uses TCP_DEFER_ACCEPT for efficient connection handling.
ServerLimit 16
StartServers 10
MaxRequestWorkers 150
MinSpareThreads 25
MaxSpareThreads 75
ThreadsPerChild 25
Advantages: Efficient resource utilization, superior high-concurrency performance Disadvantages: Limited thread safety controls
Apache Installation and Configuration
Package Installation
yum install httpd -y
File Locations (CentOS/RHEL)
| Purpose | Path |
|---|---|
| Main configuration | /etc/httpd/conf/httpd.conf |
| Include files | /etc/httpd/conf.d/*.conf |
| Module configs | /etc/httpd/conf.d/conf.modules.d/ |
| Document root | /var/www/html |
| Module directory | /usr/lib64/httpd/modules |
| Binary | /usr/sbin/httpd |
| Systemd unit | /usr/lib/systemd/system/httpd.service |
Configuration Directives
ServerName Configuration
ServerName www.example.com:80
Listen Directive
Listen 80
Listen 192.168.1.100:9527
Server Version Concealment
ServerTokens Prod
Persistent Connections
KeepAlive On
KeepAliveTimeout 15
MaxKeepAliveRequests 500
Document Root Configuration
DocumentRoot "/var/www/html"
<Directory "/var/www/html">
Require all granted
</Directory>
Default Index Files
DirectoryIndex index.html index.htm
Virtual Host Configurations
IP-Based Virtual Hosts
Listen 9527
<VirtualHost 192.168.91.3>
DocumentRoot "/var/www/site1"
ServerName www.site1.example
</VirtualHost>
<VirtualHost 192.168.91.6>
DocumentRoot "/var/www/site2"
ServerName www.site2.example
</VirtualHost>
Port-Based Virtual Hosts
Listen 80
Listen 9527
<VirtualHost *:80>
DocumentRoot "/var/www/site1"
ServerName www.example.com
</VirtualHost>
<VirtualHost *:9527>
DocumentRoot "/var/www/site2"
ServerName www.example.com
</VirtualHost>
Name-Based Virtual Hosts
<VirtualHost *:80>
DocumentRoot "/var/www/site1"
ServerName www.domain1.com
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/site2"
ServerName www.domain2.com
</VirtualHost>
IP-Based Access Control
Deny specific IP addresses:
<Directory "/var/www/protected">
<RequireAll>
Require all granted
Require not ip 192.168.1.100
</RequireAll>
</Directory>
Allow specific IP addresses only:
<Directory "/var/www/restricted">
<RequireAny>
Require all denied
Require ip 192.168.1.0/24
</RequireAny>
</Directory>
Session Management: Cookies and Sessions
HTTP operates as a stateless protocol—the server retains no memory of previous requests. This design choice optimizes server resources but creates challenges for applications requiring persistent state, such as shopping carts or authenticated sessions.
Cookies
Cookies are small text files stored on client devices by servers to maintain session state. Invented by Netscape engineer Lou Montulli in 1993, cookies work as follows:
Initial Request Flow:
- Browser sends initial request without cookie data
- Server generates cookie and returns it via Set-Cookie header
- Browser stores cookie locally
Subsequent Requests:
- Browser automatically includes cookie in request headers
- Server identifies client through stored cookie data
Primary Applications:
- Session state management (authentication, shopping carts)
- User preferences and customization
- Behavioral tracking and analytics
Session
Sessions store user data server-side, with only a session identifier transmitted to the client via cookies. Session storage can utilize memory, files, or databases.
Cookie vs Session Comparison
| Aspect | Cookie | Session |
|---|---|---|
| Storage location | Client device | Server |
| Capacity | ~4KB per cookie, limited quantity | No practical limit |
| Security | Vulnerable to client-side access | More secure, server-controlled |
| Lifespan | Temporary (session) or persistent | Managed by server |
| Performance impact | Bandwidth consumption | Server resource utilization |
Web Testing and Monitoring Tools
wget
Non-interactive file download utility supporting HTTP, HTTPS, FTP:
wget --limit-rate 1M -P /data https://example.com/file.iso
Key options: -q (quiet mode), -c (resume downloads), -O (output filename)
curl
Command-line transfer tool supporting multiple protocols:
curl -A "Mozilla/5.0" https://example.com
curl -I https://example.com # Show headers only
curl -o local.html https://example.com/page # Save to file
curl -X POST -d "data=value" https://example.com/api
curl -H "Authorization: Bearer token" https://example.com/api
Apache Benchmark (ab)
HTTP load testing utility:
ab -n 1000 -c 50 https://example.com/
Parameters: -n (total requests), -c (concurrent connections), -k (keep-alive mode)