The Chinese have their own high-performance open source network programming framework, T-IO.

After more than a decade of painstaking research on low-level technologies, China has finally polished its own completely independent open source network programming software T-IO.

1. What is T-IO

T-io is an open source network programming architecture developed based on Java. As we all know, there are many apps installed on mobile phones or computers. These apps are not used in isolation on mobile phones or computers, but can access other local data or chat with other points in real time. Therefore, each APP must have a module for external communication, which can be realized through network programming framework from the perspective of programming. T-io is the content to complete this part.

Software developers to develop a new application, the software of communication module if using tio don’t specifically to develop new communication module, thereby saving development time and can focus on other content in the grinding software, and even develop similar foreign communication network architecture, also not necessarily can achieve using t – IO communication effect, We know that a good popular APP may visit so many people at the same time, hundreds of thousands, millions or even tens of hundreds of millions of access at the same time, this is crucial for the design of the network architecture is, if the design is bad can not satisfy the such big user access APP at the same time, if there is such a big traffic and could lead to a crash, communication interrupt, Communication is too slow and so on.

T-io after the founder tan total carefully polished, super performance, has reached the level of operation, with T-IO written procedures per second can process 1000+ million messages, 1.9G memory can support 300,000 TCP long connection.

10.51 million messages per second :****

The 1.9 GB memory supports 300,000 TCP long connections :* * * *

 

Test site 1: www.tiocloud.com/41

Test site 2: www.tiocloud.com/61

Tan Chat, an instant messaging software developed based on TIO, is currently the most powerful fully open source selling instant messaging software in the industry.

www.tiocloud.com/2/product/t… 2. Data transmission in APP on network

Understand the data transmission in the network, and better understand the role of T-IO in the software. Application data in APP must be transmitted in the network, and must be fragmented and packaged according to the requirements of OSI or TCP/IP protocol to be transmitted in the IP network. So first understand the OSI and TCP/IP packet encapsulation and unencapsulation process.

OSI and TCP/IP layered stack mappingCopy the code

OSI and TCP/IP protocols and applications corresponding to each layer of the protocol stackCopy the code

The Socket is located in the TCP/IP stackCopy the code

Socket is the intermediate software abstraction layer of communication between application layer and TCP/IP protocol family. It is a group of interfaces. In the design mode, Socket is actually a facade mode, it hides the complex TCP/IP protocol family behind the Socket interface, for the user, a simple set of interfaces is all, let the Socket to organize data to conform to the specified protocol.

It can be seen from the above figure that tio performs the encapsulation between the transport layer and the application layer and establishes the connection.

The following describes the specific application process of TIO in software:

To complete the designed functions, APP must first establish an interactive communication link with or without connection between the client and the server, and then transmit data on this link. T-io can complete the establishment of this link.

APP application interactive node deploymentCopy the code

APP communication concrete implementation logic diagramCopy the code

Physical layer, refers to the transmission of electrical signals, transparent transmission bit stream.

Link layer, which transmits data in frames over a line between two adjacent nodes without error.

The network layer that provides communication between different hosts on a packet-switched network. The unit of data transfer is packet or packet.

Transport layer, responsible for the communication between two processes in the host, the unit of data transmission is message segment.

The network layer is responsible for point-to-point transport (where “point” refers to a host or router), while the transport layer is responsible for end-to-end transport (where “end” refers to source and destination hosts).

Data must be encapsulated according to TCP/IP into a standard link layer packet, and then transmitted to the peer through the physical layer. The peer party then decapsulates the data to retrieve the application layer data.

As we know from the communication process of APP explained above, if t-IO is called in the development process of various applications, more time and energy will be spent on the development of specific application functions instead of developing related network communication modules, which will save time and effort and accelerate the listing of applications.

3. T-io core module ****

T-io contains the core module tiO-core implemented by the framework, including TIo-websocket-server, TIo-HTTP-server, TIo-udp-server, TIo-webpack-core, tio-Flash-policy-server, etc. The following are application layer components developed based on TIO-Core.

Tio – core:Network programming framework based on Java AIO development. Example: Tio-study.

Tio-websocket-server: a websocket server developed based on TIO-core. Example Tio-websocket-showcase.

Tio-http-server: an HTTP server developed based on TIO-core. Example tio-http-server-showcase.

Tio-udp-server: udp server developed based on TIO-core. Example: TIo-udp-showcase.

Tio-websocket-client: a websocket client developed based on TIO-core.

Tio-webpack-core: js/ CSS/HT ML compiler and compression tool based on TIo-core.

4. T-io function description ****

TCP Server&Client: * * * *

1) Codec processing: the source file is aioHandler. Java

2) launch: the source file for TioServer. Java/TioClient Java

3) Various event processing: the source file is aiolistener.java

4) TCP connection context: The source file is channelContext.java

5) Practical method: the source file is tio.java

6) Global configuration: the source file is tioconfig.java

The HTTP Server:

The complete implementation of HTTP 1.1, t-IO internal use of a large number of TIO-HTTP, POM introduced

The Websocket Server:

Complete implementation of Websocket protocol, T-IO internal also use a large number of TIO-Websocket, POM introduction

UDP Server & Client:

Traffic monitoring and statistics:

The only network framework with complete traffic monitoring and statistics built in

Synchronizing messages:

After A sends A message to B, A waits for B to give A corresponding response message in the original thread. To achieve such A function with other network frameworks, developers need to be proficient in multi-threaded cooperation, which is easy to produce deadlocks. T-io has built-in ability to send synchronous messages, and it is also very simple to use.

Heartbeat check:

T-io has a built-in heartbeat timeout detection task. If no data is sent or received within a specified period of time, t-IO disconnects the connection.

Heartbeat sending:

T-io has the built-in task of sending heartbeat messages to determine the connection status.

Cluster function:

Enterprise T-IO has built-in clustering capabilities, which can support 100 million + long connections at the same time, simply by adding a few lines of configuration code at startup.

The cluster Server routing :

In the cluster architecture, each server has complete routing information to complete the service interaction between the servers.

In cluster architecture Message routing :

There are various routes in the clustered service that direct the business message to the relevant business node.

Protocol adapter :

T-io has built-in protocol adaptation capability, so that a set of business code can support multiple protocols at the same time, so as to avoid repeated development, repeated testing, and repeated bugs.

Concurrent data structure:

T-io creates a large number of data structures to minimize the difficulty of concurrent programming, mainly including:

ObjWithLock, ListWithLock, CollectionWithLock, SetWithLock, MapCollectionWithLock, MapListWithLock, MapSetWithLock, MapWithLock

Half sticky bag:

The framework layer has completed the work of half-packet and sticky packet, and the business layer does not need to consider the structure of packets in the transmission process, but only needs to decode according to the business protocol.

Automatic reconnection:

When t-IO is used as the TCP client, the automatic reconnection function is built-in. Users only need to configure ReconnConf objects at startup. If the automatic reconnection is implemented by the service itself, 5-10 working days are wasted for senior engineers to complete this function.

SSL features:

Secure Sockets Layer (SSL) protocol is located between TCP/IP and various application Layer protocols, providing security support for data communication. T-io supports SSL, requiring only one line of code:

serverTioConfig.useSsl(“/cert/xxx.jks”, “/cert/xxx.jks”, “password”);

IP block:

When blocking an IP address, T-IO automatically disconnects all connections from the IP address and does not accept any connections from the IP address until the service removes the IP address from the blacklist. Combined with the monitoring data of T-IO, the automatic shielding capability can be easily realized.

Lock tools:

In order to make use of read/write locks more easily, T-IO provides a lock tool class called “magic” by users to minimize the error rate of lock use. If the lock is not used properly, it is a disaster for the project. If a large number of these t-IO lock tools are used in business projects, they are both efficient and error-resistant.

Cache tools:* * * *

T-io encapsulates two levels of caches on the basis of third-party professional caches, and provides a cache tool class. With a set of programming interfaces, you can freely switch between various caches. T-io uses a large number of these cache tools to maximize performance.

Group management:

Associate multiple TCP connections to one or more groups (many-to-many). In this way, group management of upper-layer services can be easily implemented. One-to-one or one-to-many group services can be implemented.

User management :

Associate a TCP connection to a user (one-to-many)

Token management:

Associating a TCP connection with a Token (one-to-many)

Business ID management:

Associate a TCP connection to a business ID (one to one)

IP management:

One TCP connection corresponds to one client IP (one-to-many)

ID management:

A TCP connection automatically generates a unique ID (one to one)

5. T-io use cases* * * *

It is conservatively estimated that more than 10,000 enterprises are using T-IO and the number is increasing. The following shows only some companies that have used T-IO or purchased T-IO licenses.

More case, please refer to: www.tiocloud.com/2/case/inde…