SoFunction
Updated on 2025-03-04

A brief discussion on the problem of low performance of beego processing static files by default

Today I used ab (apacheBench) to test the performance of beego.

3Kbytes dynamic files can achieve 1W response per second on i3.

But when testing static files, there was a problem with beego.

ab test parameters: 100 requests, 5 concurrent numbers.

Problem manifestation: 70% of requests failed directly and the connection was disconnected.

Logically speaking, the performance of static files in a web server framework should be higher than that of dynamic files.

When the dynamic file performance reaches 1W/s, there is no reason why the static file performance is so low.

Then I checked the source code of beego. It was found that beego had cache when processing dynamic file requests. And when processing static files, there is no cache.

Brief picture:

beego --- Dynamic files --- Cache --- File system
beego---static files-----------------------------------------------------------------------------------------------------------------------

When processing static files, you use the file system directly. The concurrency volume of general file systems is of course very 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 (for the same file, the static file processing of nginx can reach 1.5W responses per second.

beego and nginx are connected through reverse proxy. This will maximize the performance of the website.

The above article briefly talks about the problem of low performance of static files by default. This is all the content I share with you. I hope you can give you a reference and I hope you can support me more.