原创

[hugo]性能极限是多少文章呢?

前言

最近想弄个静态站点,全站静态,没有一个动态页面.在研究了很多个静态站点生成的工具后,选择了hugo

hugo介绍

The world’s fastest framework for building websites
全世界最快的构建网页最快的框架

Hugo is the fastest tool of its kind. At <1 ms per page, the average site builds in less than a second.
同类静态站点生成器中,hugo最快,每页小于1毫秒,总共构建时间只需要大概1秒

结论

坑爹的是,9万文章就跑不动了

虽然测试过程极其粗糙,电脑也是普通的笔记本,安装了Majaro发行版.但是也可以管中窥豹,可以看到一丝端倪,那就是:

hugo 不要用来做静态站点生成器!!!!!

除非你静态文件少!

另外帝国cms也差劲的很,没跑多少就遇到性能瓶颈,需要加php内存了!.帝国cms适合慢慢添加文章的过程慢慢生成单个文章页,不适合批量生成大量的数据.

为什么要测试这个

静态站点靠的就是页面多,关键字才能上去,seo才能做的起来,如果只有几个页面,那完全用个动态网站生成静态页面的工具,随便跑跑就行了.为了测试这个效率,我将会用帝国ecms跟hugo进行对比.

低于1000篇文章,都不需要测试,那很快,1秒左右,现在是说1K文章以上的站点,适合不适合用hugo来进行构建呢?

测试用例说明

为了更有说服力,我使用最新版的hugo v0.98,帝国用7.5版本

文章数据两边保持一致,帝国使用新建的数据模型

hugo 使用 terminal主题,对terminal情有独钟...

页面生成md工具使用python脚本写.

两种方式使用同样的测试机器:

内存 硬盘 CPU
16G SSD 320GB I7

数据量上去后,我采用了hugo -D,不使用hugo server -D,服务器内存顶不住了...

测试的结果

文章数量 hugo生成速度 帝国cms
1000 1s 5s
2000 1.68s 20s
5000 6.69s 60s
10000 19.746s 300s
20000 68.733s 帝国没反应了
30000 152.679s 帝国没反应了
50000 421.747s ---
90000 err ----

hugo也吃内容,就算采用了文件生成的模式,内存也是节节攀升,9万条数据,无法正常生成出来,因为直接吃完了内存.

hugo测试过程

1000:
服务器内存模式

Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   |  EN   
-------------------+-------
  Pages            | 1012  
  Paginator pages  |  198  
  Non-page files   |    0  
  Static files     |   15  
  Processed images |    0  
  Aliases          | 3005  
  Sitemaps         |    1  
  Cleaned          |    0  

Built in 771 ms
Watching for changes in /home/ya/Projects/hugo/lazysite/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /home/ya/Projects/hugo/lazysite/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

2000:
服务器内存模式

[ya@ya-PC lazysite]$ hugo server -D 
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   |  EN   
-------------------+-------
  Pages            | 2012  
  Paginator pages  |  398  
  Non-page files   |    0  
  Static files     |   15  
  Processed images |    0  
  Aliases          | 6005  
  Sitemaps         |    1  
  Cleaned          |    0  

Built in 1659 ms
Watching for changes in /home/ya/Projects/hugo/lazysite/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /home/ya/Projects/hugo/lazysite/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

5000:
服务器内存模式

[ya@ya-PC lazysite]$ hugo server -D 
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   |  EN    
-------------------+--------
  Pages            |  5012  
  Paginator pages  |   998  
  Non-page files   |     0  
  Static files     |    15  
  Processed images |     0  
  Aliases          | 15005  
  Sitemaps         |     1  
  Cleaned          |     0  

Built in 6693 ms
Watching for changes in /home/ya/Projects/hugo/lazysite/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /home/ya/Projects/hugo/lazysite/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

10000:
服务器内存模式

[ya@ya-PC lazysite]$ hugo server -D 
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   |  EN    
-------------------+--------
  Pages            | 10012  
  Paginator pages  |  1998  
  Non-page files   |     0  
  Static files     |    15  
  Processed images |     0  
  Aliases          | 30005  
  Sitemaps         |     1  
  Cleaned          |     0  

Built in 19746 ms
Watching for changes in /home/ya/Projects/hugo/lazysite/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /home/ya/Projects/hugo/lazysite/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

20000:
服务器内存模式

[ya@ya-PC lazysite]$ hugo server -D 
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   |  EN    
-------------------+--------
  Pages            | 20012  
  Paginator pages  |  3998  
  Non-page files   |     0  
  Static files     |    15  
  Processed images |     0  
  Aliases          | 60005  
  Sitemaps         |     1  
  Cleaned          |     0  

Built in 68733 ms
Watching for changes in /home/ya/Projects/hugo/lazysite/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /home/ya/Projects/hugo/lazysite/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

30000:
服务器内存模式


[ya@ya-PC lazysite]$ hugo server -D 
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   |  EN    
-------------------+--------
  Pages            | 30012  
  Paginator pages  |  5998  
  Non-page files   |     0  
  Static files     |    15  
  Processed images |     0  
  Aliases          | 90005  
  Sitemaps         |     1  
  Cleaned          |     0  

Built in 152679 ms
Watching for changes in /home/ya/Projects/hugo/lazysite/{archetypes,content,data,layouts,static,themes}
Watching for config changes in /home/ya/Projects/hugo/lazysite/config.toml
Environment: "development"
Serving pages from memory
Running in Fast Render Mode. For full rebuilds on change: hugo server --disableFastRender
Web Server is available at http://localhost:1313/ (bind address 127.0.0.1)
Press Ctrl+C to stop

30000:
本地文件模式

[ya@ya-PC lazysite]$ hugo -D
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   | EN -------------------+-------- Pages | 30012  
  Paginator pages  | 5998 Non-page files |     0  
  Static files     | 15 Processed images |     0  
  Aliases          | 90005 Sitemaps |     1  
  Cleaned          | 0 Total in 167669 ms

50000:
本地文件模式

[ya@ya-PC lazysite]$ hugo -D
Start building sites … 
hugo v0.98.0+extended linux/amd64 BuildDate=unknown

                   | EN -------------------+--------- Pages |  50012  
  Paginator pages  | 9998 Non-page files |      0  
  Static files     | 15 Processed images |      0  
  Aliases          | 150005 Sitemaps |      1  
  Cleaned          | 0 Total in 421747 ms [ya@ya-PC lazysite]$

其他

我的博客即将同步至腾讯云+社区,邀请大家一同入驻:https://cloud.tencent.com/developer/support-plan?invite_code=1h4q7np8hf0uv

本文来自:[hugo]性能极限是多少文章呢?-小码农,转载请保留本条链接,感谢!

温馨提示:
本文最后更新于 2023年01月09日,已超过 712 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我
正文到此结束
本文目录