<p>Hello,</p>
<p>i'm not very experienced in regards to Go and i'm wondering how people approach optimizing their websites written in Go.</p>
<p>I'm using various libraries, f.e. storm (boltdb), go-cache, chi .... and i'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'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'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'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>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传