This is a creation in Article, where the information may have evolved or changed.
Teleport beta2.0 implements a new Golang TCP socket frame, which is versatile, efficient and flexible! Can be used for peer-peer peering, RPC, long connection gateway, microservices, push services, gaming services and other fields.
Teleport_server
1. Features
- Peer communication between server and client, the API method is basically the same
- The underlying communication packet consists
Header
of Body
two parts
- Supports individual customization
Header
and Body
encoding types, such as JSON
Protobuf
Body
Supports gzip compression
Header
Contains the status code and its description text
- Support Push, pull, reply and other communication methods
- Support plug-in mechanism, you can customize the authentication, heartbeat, micro-service registry, statistical information plug-ins.
- Graceful reboot, graceful shutdown regardless of server or client
- Support for reverse proxy functionality
- Detailed log information, support print input, output message details (status code, message header, message body)
- Support for setting the slow-action alarm threshold value
- The underlying connection uses I/O buffers
- Inter-endpoint communication using I/O multiplexing technology
AB testing 1: [Mac 4CPU 8GB] [single-process single-conn] Teleport:qps 37550
Teleport_frame_client_ab_test
AB Testing 2: [Mac 4CPU 8GB] [single-process single-conn] Teleport/socket:qps 55419
Teleport_socket_client_ab_test
2. Architecture
2.1 Name Explanation
- Peer: Communication Endpoint, possibly client or client
- Session : connect sessions, with push, pull, reply, close and other operations
- Context: processing received or sent packets
- pull-launch: pull data from peer peers
- pull-handle: processing and replying to a pull request to peer
- push-launch: pushing data to peer peers
- push-handle: handling Peer push
- Router: Handler registering a route
2.2 Level of execution
Peer -> Connection -> Socket -> Session -> Context
2.3 Data Packets
HeaderLength | HeaderCodecId | Header | BodyLength | BodyCodecId | Body
Attention:
- Headerlength:uint32, 4 bytes, big endian
- Bodylength:uint32, 4 bytes, big endian
- Headercodecid:uint8, 1 byte
- Bodycodecid:uint8, 1 byte
type Packet struct { // HeaderCodec header codec name HeaderCodec string `json:"header_codec"` // BodyCodec body codec name BodyCodec string `json:"body_codec"` // header content Header *Header `json:"header"` // body content Body interface{} `json:"body"` // header length HeaderLength int64 `json:"header_length"` // body length BodyLength int64 `json:"body_length"` // HeaderLength + BodyLength Length int64 `json:"length"`}
2.4 Head Information
type Header struct { // Packet id Id string // Service type Type int32 // Service URI Uri string // Body encoding type Gzip int32 // As reply, it indicates the service status code StatusCode int32 // As reply, it indicates the service status text Status string}
3. Open Source Project
Project Address: Https://github.com/henrylee2cn/teleport
License Agreement: Apache2.0