【问题标题】:Is there a way to increase node app render speed in heroku platform?有没有办法提高 heroku 平台中节点应用程序的渲染速度?
【发布时间】:2022-11-09 00:51:40
【问题描述】:

我在 Heorku 上部署了一个节点 appp。前端的节点应用程序使用 vanila js 和 ejs 模板来呈现 html 元素和 firebase 作为它的数据库。在开发中,我在本地主机上测试了一切,一切都很好,并且更快地呈现 html 元素,但是一旦部署在 Heroku 上,它就永远呈现我的 html元素。

我认为firestore是响应缓慢的原因。因此,当服务器启动时,我从 firestore 中提取所需的数据并将其存储在一个数组中。像这样 :

var allnewsarr =[];
function getNews(){
    console.log('running')
    
    fs.collection('news').orderBy("timestap",'desc').get().then((snaps)=>{
        snaps.forEach((fillers)=>{
            allnewsarr.push(fillers)
        });   
      found = true;
        console.log(allnewsarr.length, "are the articles")
        
        // res.send(left[0].data())
    })
    .catch((error)=>{
        repeat()
        console.log(error.message);
    })

}
server.listen(port,()=>{
    getNews()// data is extracted only when the server starts
    console.log(`The new logs ${port}`)}
    );

【问题讨论】:

  • 您是否在后端运行生产构建?

标签: node.js firebase heroku deployment


【解决方案1】:

刚刚解决了。问题是我用大量数据阻塞了发送它的 tcp。Gzip 帮助压缩并将速度提高了 4 倍

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-12-17
    • 2016-11-17
    • 1970-01-01
    • 2021-02-07
    • 2011-07-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多