为什么我的django开发服务器在本地运行比在Heroku上运行相同的开发服务器快得多?(Why is my django development server running locally so

编程入门 行业动态 更新时间:2024-10-26 08:33:32
为什么我的django开发服务器在本地运行比在Heroku上运行相同的开发服务器快得多?(Why is my django development server running locally so much faster then running the same development server on Heroku?)

我有一个使用Django的网站,在输入时从postgresql数据库中的单个表加载大约100行。

本地开发服务器 :页面加载时间为300毫秒 Heroku上的生产服务器 :页面加载1.34secs (大约慢4.13倍)(集成gunicorn并在非空闲gunicorn上从aws S3加载我的静态文件)

问心无愧?

请注意,我的生产服务器上还没有流量,我正在使用1 dyno。

当我在Heroku上使用与我的生产服务器的开发服务器完全相同的设置时,它甚至更慢。 加载时间是否正常?

我的电脑规格

Memory: 3.7 GiB Processor: Intel® Core™ i5 CPU M 520 @ 2.40GHz × 4 OS type: 64-bit

I have a website using Django that loads about 100 rows from a single table in a postgresql database when entering it.

Development server locally: Page loaded in 300ms Production server on Heroku: Page loaded in 1.34secs (about 4.13 times slower) (Integrated gunicorn and loading my static files from aws S3 on a non-idling dyno)

wth?

Note that there is no traffic yet on my production server and I am using 1 dyno.

When I used the exact same setup as my development server for my production server on Heroku it was even slower. Is such a difference in loading time normal?

Specs of my computer:

Memory: 3.7 GiB Processor: Intel® Core™ i5 CPU M 520 @ 2.40GHz × 4 OS type: 64-bit

最满意答案

根据这个来源 ,如果我的电脑有大约3.9 Gb ram和一个dyno确实有512Mb ram ,这意味着我的电脑的内存大约是7.8倍 。 根据这个来源, ram对于提高db查询的性能非常重要。 由于我做了很多询问,时间差异对我来说很有意义。

在我的heroku应用程序目录中运行顶部令人惊讶地返回35 Gb ram 。 但根据这个来源 ,在Heroku中运行top是从你的应用程序正在运行的不同的dyno(一次性dyno)执行的。

我现在唯一不理解的是为什么one-off dyno有这么多公羊。

只要没有人给出更好的答案,我会保持这个答案。

If my computer has about 3.9 Gb ram and one dyno indeed has 512Mb ram according to this source, that means my computer has about 7.8 times more ram. According to this source ram is very significant for increasing performance of db queries. Since I'm doing quite a few queries the time difference makes sense to me.

Running top in my heroku app directory surprisingly returns 35 Gb ram though. But according to this source running top in Heroku is performed from a different dyno(one-off dyno) your app is running on.

The only thing I don't understand now is why a one-off dyno has so much ram.

As long as nobody gives a better answer I'll keep this answer checked.

更多推荐

本文发布于:2023-08-03 14:26:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1391425.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:服务器   快得多   Heroku   django   development

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!