How do you approach optimizing websites?

blov · · 21 次点击    
<p>Hello,</p> <p>i&#39;m not very experienced in regards to Go and i&#39;m wondering how people approach optimizing their websites written in Go.</p> <p>I&#39;m using various libraries, f.e. storm (boltdb), go-cache, chi .... and i&#39;m sitting here wondering:</p> <p>is it worth optimizing single functions? As in: i have a simple http handlerfunc ... when benchmarking the function i get 142 allocs/op. If i remove storm and just use boltdb i get 97 allocs/op. That&#39;s 45 allocs/op less. Fair enough ... but i had to write my own functions to reduce code. Now... no matter what method i use, i will cache the rendered response anyways which results in 10 allocs/op. So trying to optimize that function seems like a waste of time to me.<br/> My question is: how important is optimizing single functions? Do you optimize every function or are you trying to find way to optimize your application in general?</p> <p>Regards </p> <hr/>**评论:**<br/><br/>SaturnsVoid: <pre><p>To be honest i don&#39;t really see the need to optimize a Go website unless you are getting massive hits a day, The nanoseconds of difference wont be noticed until you are doing a lot of database calls and serving lots of files...</p></pre>tmornini: <pre><p>Great answer!</p> <p>I wouldn&#39;t even add caching until economics demanded it, i.e. the cost of scaling the cached service outweighed the benefit of developing new features and/or refactoring code for maintainability in a simpler system.</p> <p>There are only two hard things in Computer Science: cache invalidation and naming things.</p> <p>-- Phil Karlton</p> <p><a href="https://martinfowler.com/bliki/TwoHardThings.html" rel="nofollow">There are only two hard things in Computer Science: cache invalidation and naming things. -- Phil Karlton</a></p></pre>
21 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet