University › Software and Informatics › Web Technologies
Web Architecture and the Client-Server Model
Explain the steps from a request to its response in the client-server model, and separate the scheme, domain, path and query parts of a web address.
Learning Outcomes
- In the client-server model, it can explain sequentially the steps from the beginning of a request to receiving the response.
- It can separate the scheme, domain, path and query parts of a web address and specify the function of each.
- In a three-tier architecture, the presentation can separate the responsibilities of the application and data layers.
- Can compare the security and scaling effects of keeping state information on the client or server.
Topic Explanation
The web is a distributed client-server system
The world wide web operates by providing joint services to many computers that work independently of each other. The basis of this system lies in the client-server model. The client is the component that runs on the user side and requests resources; The server is the component that responds to the request and produces a response. The two parties do not know each other directly, but only exchange messages over a defined protocol. This separation ensures that the client remains simple and the server manages resources centrally. Thousands of different clients can connect to the same server; each maintains its own session, and the server manages these sessions separately from each other.
The most important result of this model is that the parties can develop it independently. Changing the client-side interface does not require touching the server code; as long as the message format is preserved. This is called contractual development and allows two parties to work at the same time, without waiting for each other. An improvement made on the server side is reflected in the user without a new client version being deployed. The opposite is also true: a fix in the interface does not affect the server. This independence is the basis for large teams being able to work simultaneously on the same product and sets the pace for modern web development.
The responsibility boundary between client and server
The client's job is to present an interface to the user, capture user actions, and translate it into a meaningful request to the server. The browser takes on this role: it converts the address typed into the address bar into a request, interprets the response and creates a visual page, and tracks button clicks and form entries. The server's job is to authorize the request, apply the business rule, access persistent data, and send the result back as a formatted response. It is critical to draw this boundary correctly; Any data held by the user should be considered modifiable by the user.
That's why security rules and business rules are never left solely to the client. For example, stating that the field is mandatory in a form makes it easier for the user; however, if the server does not revalidate this field, a malicious client can bypass the verification. Likewise, if a total or score calculation is made on the client and the result is sent to the server, the sent value is not trusted; the calculation needs to be re-done on the server. The client exists for convenience and speed, the server exists for accuracy and trust. This principle is the common logic behind all web architecture decisions.
Addressing: URL, domain name and routing
Reaching a resource requires an address that identifies it. A web address; It contains the scheme to use, the domain name of the server, the desired path, and the optional query section. Domain names are human-readable names; must be translated into numerical addresses that the network understands. This translation is done through the domain name system, which is a distributed directory service. When the user types the domain name, the browser first asks this directory and connects to the server with the numerical address it obtains. The conversion result is temporarily kept on the local machine; Thus, when you go to the same address again, the query is not repeated and the delay is reduced.
The path part specifies which resource on the server is requested; The query part carries additional information to the request. The two parts serve different purposes: the path usually carries the identity of the resource, while the query carries options such as sorting, filtering, or pagination. Using this distinction, the server can produce different views of the same resource. The domain name system is quite durable because it is not tied to a single center; If one directory server does not respond, another one takes over. This decentralization in the addressing layer is the first condition for the web to operate on a large scale.
Three-tier architecture and layer independence
Medium and large applications are generally divided into three tiers. The presentation layer manages the interface that appears to the user. The application layer executes the business rules, understands the request, decides what data is required, and formats the response. The data layer stores persistent information, runs queries, and maintains data integrity. Thanks to this distinction, changing the interface does not affect the data structure; A change in the data schema is not reflected to the user as long as an appropriate transformation is made at the application layer. Passing only defined interfaces between layers makes the system understandable.
Separating the layers also increases testability. A function containing a business rule can be tested on its own, without the need for an interface or database; This type of testing is fast and catches the bug early. On the other hand, unnecessary dependency between layers causes a small change to affect the entire system. A well-designed layer only knows its own responsibility and not the inner details of its neighbor. This feature is called encapsulation in the software development literature and directly determines the maintenance cost.
State information and the nature of the web
The basis of web communication is the request-response cycle. When the server receives a request, it does the relevant work and sends the response; The server does not remember that user until the client sends a new request. This feature allows the server to handle each request independently and use resources efficiently. However, in flows such as a shopping cart, login status, or a multi-step form, the user's previous steps must be remembered. State management meets exactly this need: the necessary information is either kept on the client or associated with a session ID on the server.
Where to keep the state is an important architectural decision. State maintained on the client does not burden the server, but can be changed by the user; State kept on the server is more secure but incurs memory and replication costs. Most applications use both: security-critical information is stored on the server, visual preferences and temporary interface state are stored on the client. Good design is a balance where the server can re-verify with every request, while the client provides a fluid experience. If this balance cannot be established, the user will log out frequently or the server will grow unnecessarily.
Static and dynamic content
Content is presented in two basic formats. Static content are files that are provided to each user in the same way and do not require calculation on the server; An image, a style file, or an unchanging text are examples of this. Dynamic content, on the other hand, is generated during the request: such as a user-specific greeting, a list of records from the database, or a calculated result. Static content can be kept in middle layers and distributed very quickly; dynamic content requires processing on every request. This distinction is also the starting point of performance work.
In practice, most pages are a mixture of the two. While the skeleton and visual elements of the page are static, the data inside is filled dynamically. This approach makes the page look fast; the user sees the skeleton, the data is then placed. A good architecture keeps the static as static as possible and reduces dynamic generation to only the necessary places. Thus, server resources are allocated to the tasks that are actually needed. Making the distinction consciously avoids unnecessary database queries and repeated calculations.
Scaling and load distribution
A single server becomes insufficient when the number of users increases. Horizontal scaling refers to running multiple copies of the same application and distributing incoming requests among them. A load balancer on the front end routes requests to healthy replicas; If one replica fails, traffic shifts to the others. This structure increases resilience to hardware failure and makes it possible to gradually expand capacity. Vertical scaling means increasing the resources of a single server; It works up to a limited point, after which the cost increases rapidly.
For horizontal scaling to work, the application must be stateless. It shouldn't matter which copy satisfies a request; State such as session information should be kept in a shared storage. Otherwise, the user will be transferred to a different copy on the next request and his session will be lost. Therefore, architectural decisions must take into account not only today's traffic but also future growth. A design that does not bind state information to server memory from day one eliminates the need for rewriting during growth and saves teams serious time.
Measurable effects of architectural decisions
Architectural choices seem abstract but have measurable consequences. Overloading the client will cause lag and battery drain on weak devices; Overloading the server increases response time and capacity costs. A good balance is achieved by consciously deciding which side to do the work on. Predictions made without measurement are often misleading; Network latency, device power, and data size all play a role. Therefore, measurements must be taken under the same conditions before and after architectural changes.
Not only the median but also the tail of the distribution is important in measurement. While the average response time seems good, the fact that some users are waiting too long indicates a bottleneck in the system. Similarly, it is wrong to rely on the outcome of a single run; Consistency should be sought in repeated measurements and distinguished from noise. Maturity of architectural work begins with asking the right questions: which flow is slow, which resource is overused, and does the change really make a difference? Optimization without these questions is just guesswork that complicates the code.
Key Points
- The client is the one who requests the resource, the server is the one who fulfills the request; The parties communicate via a defined message format.
- The domain name system translates human-readable names into numerical addresses and is resilient thanks to its distributed structure.
- The path carries the identity of the resource, the query carries the options; The two serve different purposes.
- Horizontal scaling works fine only when the application does not migrate state.
- No client-side validation replaces server-side validation.
Worked Examples
Worked Example
Worked Example
Worked Example
Worked Example
Worked Example
Common Mistakes
- Putting the business rule only on the client and not revalidating on the server.
- Thinking that a domain name and a numerical address are the same thing; Ignoring the existence of the online service.
- Writing state information to local memory and experiencing session loss in a multi-copy environment.
- By producing all content dynamically, resources that may be static are unnecessarily calculated.
- Claiming that architectural improvement works based on a single measurement run.
Tips
- The boundary between client-specific convenience and strict authentication on the server is at the heart of secure design.
- Dynamic content is calculated on every request; static content can be kept in intermediate layers and distributed quickly.
- Shifting traffic to other replicas when one replica fails is the main task of the balancer.
- Binding session information to a single server's memory makes horizontal scaling impossible.
- Even if the average response time is good, queue delays spoil the actual user experience.
Practice Questions
- 1. What is the basic working model of the web?
- 2. Which of the following is the primary task of the client?
- 3. Which of the following is the main function of the server?
- 4. What principle explains why the parties can work without knowing each other?
- 5. What is the basic function of the domain name system?
- 6. What is the benefit of keeping domain translation local?
- 7. Which part of a web address usually carries the identity of the resource?
- 8. What is the query section typically used for?
- 9. In a three-tier architecture, at which layer are business rules executed?
- 10. Which layer protects the integrity of persistent data?
- 11. What does low inter-layer dependency provide?
- 12. Client-side validation replacing server-side validation
- 13. Which of the following is the main feature of web communication?
- 14. Why is the information required in flows such as shopping carts stored?
- 15. Where should security-critical session information be kept?
- 16. Where is information like visual theme preference typically kept?
- VOLUME 17 What is the most important feature of static content?
- 18. Which of the following is true for dynamic content?
- 19. What does horizontal scaling mean?
- 20. What is the main function of the stabilizer?
- 21. What should the implementation be like for horizontal scaling to work smoothly?
- 22. What does keeping the session in the memory of a single copy lead to?
- 23. When does the limit of vertical scaling occur?
- 24. Why is it misleading to look only at the average in architectural measurement?
- 25. Which of the following is required for a measurement to be considered reliable?
- 26 What result does the static source retained in the intermediate layers give?
- 27 What risk does putting too much work on the client create?
- 28 The most common reason for unnecessary load on the server
- 29 What is the main benefit of contract-based development?
- 30 Encapsulation provides which of the following?
- 31 The consequence of which property is that it does not matter which replica a request goes to?
- 32 What does a distributed domain name system provide?
- 33 What does correct use of path and query parts facilitate?
- 34 Reason for taking measurements before architectural change
- 35 What does having the business rule in one place prevent?
- 36 Why the value sent by a logged-in client should not be trusted
- 37 Key benefit of using shared session store
- 38 Which resource does consciously distinguishing between static and dynamic protect?
- 39 What is missed if queue latency is not measured?
- 40 What the parties agree on for independent development
- 41 Which type of scaling is increasing the resource of a single server?
- 42 To avoid a single point of failure in a distributed system
- 43 What does unnecessary inter-layer dependency lead to?
- 44. What information should a good architectural measurement report contain?
Source: Inspired by open curricula of Turkish universities; the explanation is written originally.
Kaynak: Türkiye üniversitelerinin açık ders planlarından esinlenilmiştir; anlatım özgün olarak yazılmıştır.