


Website architecture and evolution of Spring MVC code practice
This article shares with you the website architecture and evolution of Spring MVC code practice. The content is quite good. I hope it can help friends in need
Website Architecture and its evolution
Infrastructure
Network transmission decomposition method:
Standard OSI reference model
##TCP/IP Reference Model
-
##Caching and page staticization
-
Cache
- Use cache framework (Encache, Redis, Memcache)
-
Static page
-
Database optimization
-
##Table structure optimization
-
##SQL statement optimization
-
Partition
-
##Partition table
-
##Index optimization
## -
##Separate active data
-
Batch read and delayed modification
-
-
# #Distributed database
-
#NoSQL and Hadoop
High concurrency solution
- Save directly in memory through the program
- Generated using template technology (Velocity, FreeMaker, etc.)
Use stored procedures instead of direct manipulation procedures
- Separation of applications and static resources: static files ( Pictures, videos, JS, CSS, etc.) are placed on a dedicated server
-
##Common protocols and standards
TCP/IP protocol
TCP will communicate three times before transmission, which is called "three-way handshake". After transmitting the data, it will communicate four times when it is disconnected, which is called "four waves".
TCP two sequence numbers, three flag bits meaning:
seq: Indicates the sequence number of the transmitted data. Each byte during TCP transmission has a sequence number. When sending data, the first sequence number of the data will be sent to the other party. The receiver will check whether the reception is complete according to the sequence number. If the reception is not complete, it needs to be retransmitted. This way Data integrity can be guaranteed.
ack: Indicates the confirmation number. The receiving end uses it to feedback to the sending end the data information that has been successfully received. Its value is the starting sequence number of the next data packet it hopes to receive.
ACK: Acknowledgment bit, ack only works when ACK = 1. During normal communication, the ACK is 1. When the request is initiated for the first time, the ACK is 0 because there is no data that needs to be confirmed.
SYN: Synchronization bit, used to synchronize the sequence number when establishing a connection. When the connection is first established, there is no history of received data, so there is no way to set ack. This will not work according to the normal mechanism. The role of SYN is to solve this problem. When the receiving end receives the SYN = 1 report When writing, the ack will be directly set to the value of the received seq + 1. Note that the value here is not set after verification, but is set directly according to SYN, so that the normal mechanism can run, so SYN is called synchronization. Bit. SYN will be 1 in the first two handshakes, because the ack of both parties in the communication needs to set an initial value.
FIN: Termination bit, used to release the connection after the data transmission is completed.
Refer to the domain name settings, the following is my Tencent Cloud domain name settings
Record type:
A record: Point the domain name to an IPv4 address (for example: 8.8.8.8)
CNAME: Point the domain name to another domain name (for example: www.54tianzhisheng .cn)
MX: Point the domain name to the mail server address
TXT: Can be filled in arbitrarily, the length is limited to 255, usually SPF records ( Anti-spam)
NS: Domain name server record, specify the subdomain name to other DNS servers for resolution
AAAA: Point the domain name to an iPv6 address (For example: ff06:0:0:0:0:0:0:c3)
SRV: Record the server that provides a specific service (for example, xmpp-server.tcp)
Explicit URL: Redirect domain name 301 to another address
Implicit URL: Similar to explicit URL, but will hide the real target address
Host record:
To resolve www.54tianzhisheng.cn, please fill in www. The host record is the domain name prefix. Common usages are:
www: *The resolved domain name is www.54tianzhisheng.cn.
*@: Directly resolve the main domain name 54tianzhisheng.cn.
*: Pan-analytic, matching all other domain names *.54tianzhisheng.cn.
mail: Resolve the domain name to mail.54tianzhisheng.cn, which is usually used to resolve the mailbox server.
Second-level domain name: For example: abc.54tianzhisheng.cn, fill in abc.
Mobile website: For example: m.54tianzhisheng.cn, fill in m.
Usage of Socket in Java
Usage of ordinary Socket
Socket is divided into two categories: ServerSocket and Socket.
ServerSocket is used on the server side. You can listen for requests through the accept method and return the Socket after listening to the request.
Socket users specifically complete data transmission, and the client directly uses Socket to send requests and transmit data.
I just wrote a demo for unilaterally sending messages:
Client:
<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;"> import</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"> java</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;">io</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;">IOException</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">;</span>
<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;">import</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"> java</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;">io</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">. </span><span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;">OutputStream</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">;</span>
## import<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;"></span> java<span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"></span>.<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>net<span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"></span>.<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>Socket<span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;"></span>;<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>
#/**
<span style="color:rgb(79,103,117);line-height:20px;font-size:13px !important;white-space: !important;"></span>
## * Created by 10412 on 2017/5/2.
<span style="color:rgb(79,103,117);line-height:20px;font-size:13px !important;white-space: !important;"></span>
## * TCP client:
<span style="color:rgb(79,103,117);line-height:20px;font-size:13px !important;white-space: !important;"></span>
- ## ①: To establish a tcp socket service, it is best to specify the specific address and port. When this object is created, it can already connect to the specified IP and port (three-way handshake).
<span style="color:rgb(79,103,117);line-height:20px;font-size:13px !important;white-space: !important;"></span>
<span style="color:rgb(79,103,117);line-height:20px;font-size:13px !important;white-space: !important;"> ②: If the connection is successful, it means that the channel is established and the socket stream has been generated. Just get the read stream and write stream in the socket stream, and get the two stream objects through getInputStream and getOutputStream. </span>
-
#### ③: Close the resource. <span style="color:rgb(79,103,117);line-height:20px;font-size:13px !important;white-space: !important;"></span>
*/ //单方面的输入! public class TcpClient { public static void main(String[] args) { try { Socket s = new Socket("127.0.0.1", 9999); OutputStream o = s.getOutputStream(); o.write("tcp sssss".getBytes()); s.close(); } catch (IOException e) { e.printStackTrace(); } } }
Copy after login Server side:
import
<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;"> java</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">io</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">IOException</span><span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;"> ;</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>
##import
java<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;"></span>.<span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"></span>io<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>.<span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"></span>InputStream<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>;<span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;"></span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>
import
java<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;"></span>.<span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"></span>net<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>.<span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"></span>ServerSocket<span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>;<span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;"></span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;"></span>
<span style="color:rgb(199,146,234);line-height:20px;font-size:13px !important;white-space: !important;">import</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;"> java</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(238,255,255);line-height:20px;font-size:13px !important;white-space: !important;">net</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">.</span><span style="color:rgb(126,165,247);line-height:20px;font-size:13px !important;white-space: !important;">Socket</span><span style="color:rgb(204,204,204);line-height:20px;font-size:13px !important;white-space: !important;">;</span>
/** * Created by 10412 on 2017/5/2. */ public class TcpServer { public static void main(String[] args) { try { ServerSocket ss = new ServerSocket(9999);//建立服务端的socket服务 Socket s = ss.accept();//获取客户端对象 String ip = s.getInetAddress().getHostAddress(); int port = s.getPort(); System.out.println(ip + " : " + port + " connected"); // 可以通过获取到的socket对象中的socket流和具体的客户端进行通讯。 InputStream ins = s.getInputStream();//读取客户端的数据,使用客户端对象的socket读取流 byte[] bytes = new byte[1024]; int len = ins.read(bytes); String text = new String(bytes, 0, len); System.out.println(text); //关闭资源 s.close(); ss.close(); } catch (IOException e) { e.printStackTrace(); } } }
Copy after login
The above is the detailed content of Website architecture and evolution of Spring MVC code practice. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



In 2023, AI technology has become a hot topic and has a huge impact on various industries, especially in the programming field. People are increasingly aware of the importance of AI technology, and the Spring community is no exception. With the continuous advancement of GenAI (General Artificial Intelligence) technology, it has become crucial and urgent to simplify the creation of applications with AI functions. Against this background, "SpringAI" emerged, aiming to simplify the process of developing AI functional applications, making it simple and intuitive and avoiding unnecessary complexity. Through "SpringAI", developers can more easily build applications with AI functions, making them easier to use and operate.

Websites for learning C language: 1. C Language Chinese Website; 2. Rookie Tutorial; 3. C Language Forum; 4. C Language Empire; 5. Script House; 6. Tianji.com; 7. Red and Black Alliance; 8, 51 Self-study network; 9. Likou; 10. C Programming. Detailed introduction: 1. C language Chinese website, which is a website dedicated to providing C language learning materials for beginners. It is rich in content, including basic grammar, pointers, arrays, functions, structures and other modules; 2. Rookie tutorials, This is a comprehensive programming learning website and more.

As an industry leader, Spring+AI provides leading solutions for various industries through its powerful, flexible API and advanced functions. In this topic, we will delve into the application examples of Spring+AI in various fields. Each case will show how Spring+AI meets specific needs, achieves goals, and extends these LESSONSLEARNED to a wider range of applications. I hope this topic can inspire you to understand and utilize the infinite possibilities of Spring+AI more deeply. The Spring framework has a history of more than 20 years in the field of software development, and it has been 10 years since the Spring Boot 1.0 version was released. Now, no one can dispute that Spring

SpringDataJPA is based on the JPA architecture and interacts with the database through mapping, ORM and transaction management. Its repository provides CRUD operations, and derived queries simplify database access. Additionally, it uses lazy loading to only retrieve data when necessary, thus improving performance.

Paper address: https://arxiv.org/abs/2307.09283 Code address: https://github.com/THU-MIG/RepViTRepViT performs well in the mobile ViT architecture and shows significant advantages. Next, we explore the contributions of this study. It is mentioned in the article that lightweight ViTs generally perform better than lightweight CNNs on visual tasks, mainly due to their multi-head self-attention module (MSHA) that allows the model to learn global representations. However, the architectural differences between lightweight ViTs and lightweight CNNs have not been fully studied. In this study, the authors integrated lightweight ViTs into the effective

The learning curve of the Go framework architecture depends on familiarity with the Go language and back-end development and the complexity of the chosen framework: a good understanding of the basics of the Go language. It helps to have backend development experience. Frameworks that differ in complexity lead to differences in learning curves.

Introduction In today's rapidly evolving digital world, it is crucial to build robust, flexible and maintainable WEB applications. The PHPmvc architecture provides an ideal solution to achieve this goal. MVC (Model-View-Controller) is a widely used design pattern that separates various aspects of an application into independent components. The foundation of MVC architecture The core principle of MVC architecture is separation of concerns: Model: encapsulates the data and business logic of the application. View: Responsible for presenting data and handling user interaction. Controller: Coordinates the interaction between models and views, manages user requests and business logic. PHPMVC Architecture The phpMVC architecture follows the traditional MVC pattern, but also introduces language-specific features. The following is PHPMVC

How to set the transaction isolation level in Spring: 1. Use the @Transactional annotation; 2. Set it in the Spring configuration file; 3. Use PlatformTransactionManager; 4. Set it in the Java configuration class. Detailed introduction: 1. Use the @Transactional annotation, add the @Transactional annotation to the class or method that requires transaction management, and set the isolation level in the attribute; 2. In the Spring configuration file, etc.
