The following content is from the user’s original manuscript of “Tencent Cloud Serverless Web Function”, and has been authorized.

Preface to the 01.

Recently, Tencent Cloud SCF cloud function has publicly tested Web functions, which focus on Serverless Web service scenarios.

Compared with the original Event function, the Web function has shorter conversion links and lower performance loss.

  • The original Even T function: THE ApI gateway converts HTTP requests into SCF function events, which are then converted into HTTP requests within SCF and sent to the Web framework for processing.

  • Now Web functions: at the API gateway, HTTP requests are passed through directly. Functions can be triggered directly through HTTP requests, which gives it a natural advantage in Web scenarios.

Here, the author deploys 8 use cases for the Event function and Web function of the same code to continuously increase the concurrency and conduct stress tests to explore the impact of different function types and Runtime on QPS,TPS, and Latency.

02. Test cases

  1. [event-node10]Use:serverless expressDeployed onenode10.15Event SCF;
  2. [event-node12]Use:serverless expressDeployed onenode12.16Event SCF;
  3. [web-node10]Use:serverless scfDeployed onenode10.15Web type SCF;
  4. [web-node12]Use:serverless scfDeployed onenode12.16Web type SCF;
  5. [web-custom-image-node10]: Uses a custom mirrornode10A Web type SCF for deployment;
  6. [web-custom-image-node12]: Uses a custom mirrornode12A Web type SCF for deployment;
  7. [web-custom-image-node14]: Uses a custom mirrornode14A Web type SCF for deployment;
  8. [web-custom-image-node16]: Uses a custom mirrornode16A Web type SCF for deployment;

Note: The Web framework used is the most popular NodeJS Express, which only contains calculations without IO operations. Custom images of Node.js are used in alpine version.

Among them, the prefabricated concurrent instances of the function are 10, and warm up is done in advance, the memory is 128MB (the custom image is different, has its own memory rules), and the local pressure test code is the same configuration:

  • The pressure measurement time of each function is10s, concurrent number10Phi is a gradient, plus phi100.Fire RequestIs a Get request.

03. Chart of test results data

This chart can be interactive (it is suggested to open it on PC, the author did not make mobile compatible)

  • Icebreaker. Top /chart/ SCF-E…

1. Average QPS (Avg Req/Sec)

  • Req_Sec average line chart

As you can see from the line graph below, the number of requests processed per second increases as the number of concurrent requests increases. And you can also see that as the concurrency increases, the Web function becomes more and more distant from the Event function.

  • Req_Sec average cumulative histogram

From the cumulative bar chart below, it is clear that the average QPS of the Web type is higher than that of the Event type. Runtime also uses Node12 slightly higher than Node10, which may have been optimized for later versions of Node.js.

2. Average TPS (Avg Bytes/Sec)

  • Bytes_Sec Average line chart of throughput (KB)

As you can see from the line graph below, throughput increases as the amount of concurrency increases. You can also see that as the number of concurrent functions increases, the Web function is gradually pulling away from the Event function, but the gap is much smaller than that of QPS.

  • Bytes_Sec Throughput (KB) average cumulative bar chart

From the cumulative bar chart below, it is clear that the average TPS of the Web type is higher than that of the Event type, but the difference is not that large. Node12 is also slightly higher than Node10.

3. Avg Latency

  • Latency Average line chart of Latency

From the figure below, it is clear that as the amount of concurrency increases, the latency does not increase and gradually stabilizes. The average latency is about 30-50ms, and the average latency of the Web type is obviously lower than that of the Event type.

This means that functions are also faster to respond to user requests, and Node12 is also slightly (and negligible) faster than Node10.

04. Summary

1. Performance improvement

  1. SCF single function concurrency, and QPS, TPS proportional (automatic scaling);
  2. Compared with the Event function, the Web function has more advantages in handling HTTP requests with the increase of concurrency.
  3. Web functions process HTTP requests with lower latency than Event functions;
  4. The Runtime version of Node.js is also affected, with Node.js12.16 outperforming Node10.15 in all aspects.

2. Improved developer experience

Web functions have also greatly improved the development and debugging experience for us developers locally.

  • Before

We originally deployed an Event function to handle HTTP requests, often writing code to export an instance of a framework (express, KOA, Nuxt, Next…). The Serverless component is deployed, but different Web frameworks often require different shippers (Event conversion HTTP) for deployment, resulting in high coupling between the “Event function” and the “Serverless component”.

  • After

The Web function doesn’t need to be strongly associated with those Web frameworks, it just needs to be told a listening port number, regardless of what framework we developers use to Host our Web service. We can install any framework locally and deploy it without having to find Serverless components for the corresponding framework.

At the same time, it is very friendly to the migration of some existing systems. It can even be as simple as one-click deployment on the cloud by changing the monitoring port number, reducing a lot of time spent on operation and maintenance deployment.

So Web functions are a revolution!

It makes the original Event-based Serverless Components Web Components useless, and it’s time to dump them and embrace Web functions.

In a word:

If we developers want to write or migrate a Web service to Serverless, then Tencent cloud SCF Web function is your first choice!

P.S.

The author is not a professional test, all test results are for reference only, but also welcome professional advice and opinions.

This time, we also tested the deployment of Web function + custom mirror, but the test results were messy and no rules were found. We will conduct further tests for this scenario.

New technology is developing rapidly. This paper was written in 2021.07.08. There are certain historical limitations.

A link to the

Deploy code and pressure code

Address of the chart

Serverless Components Web framework address based on event

Web Function Experience Officer Recruitment order

Surprise full of benefits, click to see the details of the event

Web Function experience

  • Web Function Product Documentation:

    Cloud.tencent.com/document/pr…

  • Web Function quick Experience link:

    Console.cloud.tencent.com/scf/list-cr…

At present, it has been released online in various regions in China. Welcome to experience and use it!

One More Thing

Experience Tencent Cloud Serverless Demo immediately and receive Serverless new user package 👉 Tencent Cloud Serverless novice experience

Welcome to: Serverless Chinese!