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(); } } }
- 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(); } } }
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!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

Zend Studio 13.0.1
Powerful PHP integrated development environment