Web application architecture C/S architecture
Web applications use the C/S architecture from the outset. The server listens for client requests, provides resources, and client initiates requests to the server and renders the page. Both communicate via the HTTP protocol above the TCP/IP protocol stack.
Multilayer architecture
In the Web 2.0 era, this architecture became more complex with the requirement of interactivity. The server needs to provide more complex services, and the client has to complete many other interactive tasks, and there are many new technologies that provide faster and better service. Correspondingly, the C/s architecture needs to be organized in a more complex way, namely multilayer architectures.
Each layer in the multilayer architecture is responsible for providing a specific function that interacts with the other layers through a good interface and is easy to upgrade and maintain. The original C/s architecture can be regarded as server, client two layer.
3-tier architecture
A typical 3-tier architecture is the presentation layer, the logical layer, the data layer
- The presentation layer is rendered by the browser
- The logical layer manipulates the data from the server side and goes to the presentation layer
- The data layer is responsible for storing the data.
6-tier architecture
Assuming a further cut, you get a 6-tier architecture, such as
- The presentation layer is divided into the client layer and the presentation logic layer
- The client layer is responsible for rendering the display page
- Indicates that the logical layer generates Web pages for the server by script
- Logical layer is divided into business logic layer and data access layer
- transaction logic Layer characterization transaction logic and flow
- data access layer is responsible for accessing data and sending it to the transaction logic layer
- The service side usually has the network layer responsible for the network
Ruby on Rails
Ruby on Rails is an open-source framework or open-source library for building Web applications based on Ruby, and companies like Twitter, Hulu, Github, and Iteye are using rails
Framework.
Component
Ruby on Rails includes a range of components
- Rake: Similar to make, can be used to change, migrate databases
- Webrick: A rails built-in HTTP server that can be started with the Rails Server command, is slower, and is suitable for testing in the development phase
- SQLite: The simplest database, the same test that is only suitable for the development phase
- Rack Middleware: Middleware for interaction between server software and applications
Disadvantages
- Not suitable for massive services, Twitter has shifted from Ror to Scala
- It's a frame that hides too much detail
MVC architecture
Model represents data, view uses data to render pages, and controller is the medium. The strict separation of view and model preserves reusability.
When you create an app using rails, you generate the relevant code on your own initiative in accordance with the MVC schema, including:
- Represents a class of model in which the corresponding table is established in the database
- A controller, the corresponding URL resolution and database operations will be the corresponding good
- View contains a series of HTML files to render the page
Active Record
The Active record mechanism makes object-relational mapping (ORM) feasible. Appears as a ActiveRecord module in Ruby. The ORM mapping mechanism is:
- Class-table
- Object-record (one row of the table)
- Attribute-record value (a column of the table)
The ActiveRecord module provides the following features:
- Establish a connection to the database
- Creation of tables
- ORM Mapping
- Use object to complete CRUD operations (Create, Read, Update, Delete)
Reprint please specify FOCUSTC, blog address for HTTP://BLOG.CSDN.NET/CAOZHK, the original link for Click Open