Tars
Tars is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.
Top Related Projects
an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
Distributed reliable key-value store for the most critical data of a distributed system
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
AWS Service registry for resilient mid-tier load balancing and failover.
Apache ZooKeeper
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
Quick Overview
Tars is an open-source microservices framework developed by Tencent. It provides a comprehensive solution for building, deploying, and managing microservices applications, supporting multiple programming languages and offering features like service discovery, load balancing, and monitoring.
Pros
- Multi-language support (C++, Java, PHP, Node.js, Go)
- Comprehensive microservices ecosystem with built-in tools for deployment, monitoring, and management
- High performance and scalability, suitable for large-scale distributed systems
- Active community and continuous development backed by Tencent
Cons
- Steeper learning curve compared to some other microservices frameworks
- Documentation and resources primarily in Chinese, which may be challenging for non-Chinese speakers
- Limited adoption outside of China, potentially affecting the global ecosystem and support
Code Examples
- Defining a Tars servant interface (C++):
module Hello
{
interface HelloWorld
{
int hello(string name, out string greeting);
};
};
- Implementing the servant (C++):
class HelloWorldImp : public Hello::HelloWorld
{
public:
virtual int hello(const string &name, string &greeting, tars::TarsCurrentPtr current)
{
greeting = "Hello, " + name;
return 0;
}
};
- Creating a Tars server (C++):
int main(int argc, char* argv[])
{
try
{
Application app;
HelloWorldImp obj;
app.addServant<HelloWorldImp>(obj, "HelloWorld.HelloWorldObj");
app.run();
}
catch (std::exception& e)
{
cerr << "std::exception:" << e.what() << std::endl;
}
catch (...)
{
cerr << "unknown exception." << std::endl;
}
return -1;
}
Getting Started
-
Install Tars framework:
git clone https://github.com/TarsCloud/Tars.git cd Tars ./install.sh
-
Create a new Tars project:
tars-create-project MyProject cd MyProject
-
Implement your service logic in the generated files.
-
Build and deploy your project:
make make tar tars-deploy MyProject.tgz
-
Access your service through the Tars web administration platform or client SDKs.
Competitor Comparisons
an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
Pros of Nacos
- More comprehensive service management features, including service discovery, configuration management, and dynamic DNS services
- Better support for cloud-native architectures and microservices
- More active community and frequent updates
Cons of Nacos
- Steeper learning curve due to more complex features
- Higher resource consumption compared to Tars
Code Comparison
Nacos configuration example:
@NacosPropertySource(dataId = "example", autoRefreshed = true)
public class NacosConfig {
@NacosValue("${useLocalCache:false}")
private boolean useLocalCache;
}
Tars configuration example:
#include "servant/Application.h"
class HelloServer : public Application
{
public:
virtual void initialize() {};
virtual void destroyApp() {};
};
Both Tars and Nacos provide service registration and discovery capabilities, but Nacos offers a more comprehensive set of features for modern cloud-native applications. Tars, on the other hand, is simpler and may be easier to implement for smaller projects or teams new to microservices architecture. The choice between the two depends on the specific requirements of your project and your team's expertise.
Distributed reliable key-value store for the most critical data of a distributed system
Pros of etcd
- Highly reliable distributed key-value store with strong consistency guarantees
- Widely adopted in the Kubernetes ecosystem for service discovery and configuration management
- Simple API and easy integration with various programming languages
Cons of etcd
- Limited to key-value storage, lacking advanced data structures or complex querying capabilities
- May require additional components for complete microservices architecture implementation
- Potential performance bottlenecks in large-scale deployments with frequent updates
Code Comparison
etcd example:
cli, _ := clientv3.New(clientv3.Config{Endpoints: []string{"localhost:2379"}})
defer cli.Close()
ctx, cancel := context.WithTimeout(context.Background(), time.Second)
_, err := cli.Put(ctx, "key", "value")
cancel()
Tars example:
HelloServantPrx prx = Application::getCommunicator()->stringToProxy<HelloServantPrx>("HelloServer.HelloServant.HelloObj");
try {
string ret = prx->hello("world");
cout << ret << endl;
} catch(exception &ex) {
cerr << "exception: " << ex.what() << endl;
}
While etcd focuses on distributed key-value storage, Tars provides a more comprehensive microservices framework with RPC capabilities. etcd is often used as a component within larger systems, whereas Tars offers an all-in-one solution for building and managing microservices architectures.
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
Pros of Consul
- More mature and widely adopted in the industry
- Offers a broader range of features, including service discovery, health checking, and key-value store
- Better documentation and community support
Cons of Consul
- Can be more complex to set up and configure
- Requires additional components for full functionality (e.g., Consul Connect for service mesh)
- May have higher resource consumption for smaller deployments
Code Comparison
Consul configuration example:
service {
name = "web"
port = 80
check {
http = "http://localhost/health"
interval = "10s"
}
}
Tars configuration example:
<tars>
<application>
<server>
app=TestApp
server=HelloServer
localip=127.0.0.1
port=10015
</server>
</application>
</tars>
Both examples show basic service configuration, but Consul's configuration is more focused on service discovery and health checking, while Tars' configuration is centered around application and server settings.
AWS Service registry for resilient mid-tier load balancing and failover.
Pros of Eureka
- Widely adopted in the Spring ecosystem, with extensive documentation and community support
- Simpler setup and configuration for Java-based microservices
- Built-in REST API for service registry operations
Cons of Eureka
- Limited language support, primarily focused on Java
- Less comprehensive features compared to Tars (e.g., lacks built-in load balancing)
- May require additional components for full service mesh functionality
Code Comparison
Eureka client registration (Java):
@EnableEurekaClient
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Tars servant registration (C++):
#include "HelloServant.h"
#include <servant/Application.h>
int main(int argc, char* argv[])
{
try
{
Application app;
app.addServant<HelloServant>("Hello.HelloObj");
app.run();
}
catch (std::exception& e)
{
cerr << "std::exception:" << e.what() << std::endl;
}
catch (...)
{
cerr << "unknown exception." << std::endl;
}
return -1;
}
Apache ZooKeeper
Pros of Zookeeper
- More mature and widely adopted in the industry
- Better documentation and community support
- Offers a simpler API for distributed coordination tasks
Cons of Zookeeper
- Heavier resource consumption, especially for small-scale applications
- More complex setup and configuration process
- Limited built-in support for service discovery and load balancing
Code Comparison
Zookeeper client code (Java):
ZooKeeper zk = new ZooKeeper("localhost:2181", 3000, watcher);
String path = zk.create("/mynode", "mydata".getBytes(), ZooDefs.Ids.OPEN_ACL_UNSAFE, CreateMode.EPHEMERAL);
Tars client code (C++):
Communicator comm;
HelloPrx prx;
comm.stringToProxy("HelloObj@tcp -h 127.0.0.1 -p 10000", prx);
string ret = prx->hello(1000, "world");
While both frameworks provide distributed coordination capabilities, Zookeeper focuses on providing a robust foundation for building distributed systems, whereas Tars offers a more comprehensive microservices framework with additional features like service management and deployment tools. The code examples demonstrate the difference in API complexity, with Zookeeper requiring more explicit setup for basic operations compared to Tars' more abstracted approach.
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
Pros of gRPC
- Wider language support and ecosystem
- Better performance for large-scale, high-load systems
- More extensive documentation and community resources
Cons of gRPC
- Steeper learning curve, especially for developers new to RPC
- Less flexibility in protocol customization
- Potentially more complex setup and configuration
Code Comparison
gRPC example (Python):
import grpc
import helloworld_pb2
import helloworld_pb2_grpc
def run():
with grpc.insecure_channel('localhost:50051') as channel:
stub = helloworld_pb2_grpc.GreeterStub(channel)
response = stub.SayHello(helloworld_pb2.HelloRequest(name='you'))
print("Greeter client received: " + response.message)
Tars example (C++):
#include "HelloServant.h"
class HelloServantImpl : public Hello::HelloServant {
public:
virtual int hello(const std::string &sReq, std::string &sRsp, tars::TarsCurrentPtr current) {
sRsp = "hello " + sReq;
return 0;
}
};
Both frameworks provide efficient RPC communication, but gRPC offers broader language support and better performance for large-scale systems. Tars, while less widely adopted, may be easier to learn and offers more flexibility in protocol customization. The choice between the two depends on specific project requirements and team expertise.
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual CopilotREADME
TARS - A Linux Foundation Project
- TARS Foundation Official Website
- TARS Project Official Website
- WeChat Offical Account: TarsCloud
- QQ Group: 733605310, 579079160(Full), 669339903(Full)
- Twitter: @TarsCloud
- Mailing List
- Contacts
What is TARS?
TARS is a Linux Foundation project. It is a high-performance RPC framework based on name service and Tars protocol, also integrated administration platform, and implemented hosting-service via flexible schedule.
Tars, aka TAF(Total Application Framework), has been used in Tencent since 2008. It supports C++, Java, Nodejs and PHP for now. This framework offers a set of solution for development, maintenance and testing, which making development, deployment and testing service efficiently. It integrated extensible protocol for encoding/decoding, high-performance RPC communication framework, name service, monitor, statistics and configuration. You can use it to develop your reliable distributed application based on microservice fast, and reach fully efficient service management.
Nowadays it's used by hundreds of bussiness in Tencent, services that developed base on TAF run on 16 thousands of machines.
See the detailed introduction SUMMARY.md.
Supported platforms
For now it supports OS as below:
- Linux
- Mac(>=2.1.0 support)
- Windows (>= Windows 7)
Supported languages
For now it supports following languages:
- C++
- Java
- Nodejs
- PHP
- Go
Version Management
Tars is composed of many modules, scattered in many warehouses, and the basic framework version and language version can develop independently. In view of this, from version 2.1.0, the Framework version tag is printed on the tarsframework warehouse, no longer reflected in the tars warehouse
In addition, each component will have its own version. When there is a version dependency specification, each component will have its own version
Installation
- If you are new to Tars, please read documentation installation.
- First deploy, please read documentation source.
- Install by docker, detail information: dockerã
Submodule
Directory | Features |
---|---|
framework | Source code implementation of C++ language framework basic service |
cpp | C++ language framework rpc source code implementation |
java | java language framework rpc source code implementation |
go | go language framework rpc source code implementation |
nodejs | nodejs language framework rpc source code implementation |
php | php language framework rpc source code implementation |
tup | source code implementation of tup group protocol in each language |
web | manage tars web source implementation |
Developer's documentation
See docs.
License
The open-source protocol Tars used is BSD-3-Clause, see LICENSE.md.
Chinese Version
Top Related Projects
an easy-to-use dynamic service discovery, configuration and service management platform for building cloud native applications.
Distributed reliable key-value store for the most critical data of a distributed system
Consul is a distributed, highly available, and data center aware solution to connect and configure applications across dynamic, distributed infrastructure.
AWS Service registry for resilient mid-tier load balancing and failover.
Apache ZooKeeper
The C based gRPC (C++, Python, Ruby, Objective-C, PHP, C#)
Convert designs to code with AI
Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.
Try Visual Copilot