Performance question ?

agolangf · · 478 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>We currently have api built using Django Rest Framework which uses Gearman client + MySQL 5.7 in backend.Is it possible to migrate into Go and if we do migrate will it be faster than django. </p> <hr/>**评论:**<br/><br/>jackmott2: <pre><p>It might be faster than django if your code is currently slow because of CPU-bound issues in the python code, rather than slow because of database tuning, design, queries, or other architectural issues like overly large javscript/css packages, images, and so on.</p> <p>So first be sure you know why things are slow. If for sure it is the python code, first think about whether more modest changes to the python could make it faster. Can you memoize things that you are computing a lot? Can you organize your data in memory better, better algorithms? </p> <p>But yes it is possible to migrate to Go, but a ton of work if your project isn&#39;t small, and if it was a line for line rewrite it would almost certainly be faster.</p></pre>pratik252: <pre><p>new relic shows that python&#39;s function call overhead is greater than MySQL query execution time</p></pre>jrwren: <pre><p>I don&#39;t know much about new relic, but I&#39;m surprised that it can tell you that. How does it determine that?</p></pre>shovelpost: <pre><blockquote> <p>Is it possible to migrate into Go and if we do migrate will it be faster than django.</p> </blockquote> <p>Well everything is possible. But will it be faster? Nobody knows. It depends. Usually data indicate that <a href="https://github.com/golang/go/wiki/FromXToGo" rel="nofollow">rewrites from Python to Go</a> lead to increase performance. But rewrites are incredibly complex. And for every success story that we know there might be one or more failure stories that we do not know.</p> <p>My suggestion is to isolate a small part of your application, maybe one that is performance critical and migrate just that. Or maybe write a new feature in Go. Then measure and learn from that experience.</p></pre>curiousGambler: <pre><blockquote> <p>But rewrites are incredibly complex.</p> </blockquote> <p>Seriously, repeat this to yourself ten times every night before bed for a week and really grasp what you&#39;re getting into before your make this decision.</p> <p>You can take a snippet of Python code and port it to Go pretty easily, but that ease does not extend to porting an entire application. The package structures, norms, etc. of the languages are different and a port could require significant re-architecture, or worse, you might end up with a Go app jammed into a Python package style if you refuse to perform that re-architecture when necessary.</p> <p>A port can be a huge boon to your business if done well, but you need to understand what you&#39;re getting into first, because it can also kill a business if done poorly.</p></pre>justinisrael: <pre><p>As others have said, it is likely it could be faster but you won&#39;t know until you test. Also, Django isn&#39;t the fastest python Web framework anyways. It is just a convenient monolithic Web framework. Aside from performance, your deployments should become easier when migrating it to Go. Django usually requires multiple uwsgi processes to scale it out on a single machine. And it also requires a virtual environment for all your dependencies. Go will be a static binary. It also properly utilizes multiple cores so you only need one instance on the host. </p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

478 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传