With the development of the Internet, more and more services can be carried by not only a single node (or a single language), but also multi-language distributed collaborative development (such as the access layer is completed by Node.js, ) Layer is implemented by C ++ / GO / Python) and from this form a large heterogeneous system.
We developed Tars.js based on the Tars system so that users can quickly build (migrate) Node.js services without changing the overall architecture of heterogeneous systems, and it is very convenient Split the original single service into multiple (logical) subservices.
Tars.js has been accumulated and iterated in Tencent for more than 5 years (supported by the Node.js@0.10 version), and is widely used in Tencent QQ browser, Tencent desktop browser, Tencent map, App treasure, Tencent mobile butler, Internet +, Tens Medical, Tencent Medical, insurance, lottery and other dozens of important businesses, Japan has undertaken tens of billions of traffic.
In other words:
You can use any framework you are familiar with (such as Express.js / Koa.js, including but not limited to web frameworks), and you don't need to modify the framework (without introducing any middleware). You can run it through Tars.js and enjoy the various monitoring and management features provided by the platform.
At the same time, the modules provided by Tars.js can also be imported according to your needs (or not imported if not used).
Tars.js is designed for high performance and large concurrency, and uses a large number of front-end (V8) optimization techniques (such as FlattenString / FastProperties, etc.) to minimize the impact of the capabilities provided on business performance.
After our testing (Web Server), the default impact of bypass reporting and monitoring on service performance is ≤ 5%, and the performance of commonly used modules (RPC, logs, etc.) is among the best in the industry.
Tars.js provides differentiated operation solutions according to different business types:
Due to the limited space, I can't show all the capabilities. If you have more requirements (such as RPC calls, etc.), you can use the modules provided by Tars.js (as follows):
Each module (click the name to jump) has extremely detailed documentation (README) for you to consult at any time.
On the Tars platform-> Service Management-> Service Go Online, launch a new service:
Install the @ tars/deploy packaging tool.
npm i -g @ tars / deploy
Choose the framework based on your business needs and your preferences (!Tars.js does not limit the framework you use!), Write your business code:
const http = require('http');
const hostname = process.env.IP || '127.0.0.1'; const port = process.env.PORT || 3000;
const server = http.createServer((req, res) => { res.statusCode = 200; res.setHeader('Content-Type', 'text/plain'); res.end('Hello World\n'); });
server.listen(port, hostname, () => {
console.log(Server running at http://${hostname}:${port}/
);
});
The above is an example of [HTTP Server](https://nodejs.org/en/about/) on the official website of Node.js. It only needs to modify the IP and port to run on the `Tars.js` platform.
The IP and PORT obtained in the environment variables here are the IP and port in the OBJ deployment information you configured in the first step.
4. Execute the packaging tool in the project root directory to generate the release package HelloWorld.tgz:
tars-deploy HelloWorld
5. On the Tars platform, select the service you just created-> Release Management-> Manually upload the release package, and then publish this version.
6. You can access your services through the IP and port you configured in the first step.