Discussion on the poor performance of beego's default handling of static files

  • 2020-06-03 06:55:33
  • OfStack

Today, ab (apacheBench) was used to test 1 beego performance.

3Kbytes dynamic file with 1W response per second on i3.

However, beego had problems testing static files.

ab test parameters: 100 requests, concurrency 5.

Problem performance: 70% of requests directly fail and the connection is disconnected.

In principle, an web server framework should have better static file performance than dynamic file performance.

With dynamic file performance at 1W/s, there is no reason for static file performance to be so poor.

Then I looked at the source code for beego 1. Found that beego has a cache while processing dynamic file requests. When working with static files, there is no cache.


beego- Dynamic file - cache - File system
beego-- Static file -- file system

When working with static files, you use the file system directly. The concurrency of a 1 - like file system is certainly low.

This is why beego's static file processing performance is poor.

Therefore, when deploying a website, the corresponding static file needs to be placed on nginx for processing (the static file processing of nginx can achieve 1.5W responses per second for the same file).

beego and nginx are connected via a reverse proxy. This way you can maximize your website performance.

Related articles: