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 the 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 do more interactive tasks, and there are many new technologies that provide faster and better services. Accordingly, the C/s architecture needs to be organized in a more complex way, that is, multilayer architectures.
Each layer in a multilayer architecture is responsible for providing a specific function that interacts with other tiers 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
If you divide it further, 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 based on the script
- The logical layer is divided into the business logic layer and the 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 all use rails
Framework.
Component
Ruby on Rails contains a series of components
- Rake: Similar to make, can be used to modify, migrate databases
- Webrick: A rails built-in HTTP server that can be started with the Rails Server command, slower, and ready for the development phase of the test
- SQLite: The simplest database, also suitable only for the development phase of the test
- 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, it automatically generates the relevant code according to the MVC schema, including:
- Represents a class of model, and the corresponding table is created in the database
- A controller, the corresponding URL resolution and database operations will be a good match
- View includes 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