This is a creation in Article, where the information may have evolved or changed.
Why am I moving from python to go language
(2013-05-03 15:12:34)
reproduced
| tags: go language python it |
software |
Why am I from python Steering Go language
Chenyehao@gmail.com
2013-5-3
headlines always attract attention, but I still python enthusiasts, everyone needs to use the right tools to solve specific problems.
me from2004year to start usingpython, before that, I usedPerl. pythonsimple syntax, support object-oriented, support exception handling, rich third-party code base, greatly improve the development efficiency. After that, I've been usingpython, developing enterprise software, automation tools, and small websites.
and then in -years, I joined the picture class(kantuban.com)the start-up company continues to usepythondevelopment of Internet products. We useTornadoto developWebFront desk, as well as back-office services. Until I useTornadoThe background service developed is encountering a performance bottleneck.
This is a cache plus algorithm service that needs to be loaded from the database 800 2.1g memory, initialize load data time (that is, start time) 30 minutes. The average response time for the service is in 10ms below.
 
The question is, python cpu When performing individual time-consuming tasks, other requests are blocked (where non-blocking programming patterns do not work because they are dense computations and cannot push compute tasks out of the process). If you rely on starting multiple instances to increase the load, each instance needs to occupy 2.1g . Span style= "word-wrap:normal; Word-break:normal; Font-family: Song body "> memory, also consider data synchronization between processes. The conclusion is that we need to support multithreaded multi-core programming languages. If you start with java
Finally, I decided to adopt Go language. Simple syntax is similar to python, which supports multiple cores from the language (without writing code to create threads, requiring only global specified concurrency), while static languages save memory.
It took me one months to get the code frompythonported toGo, you can basically do a linepythoncode corresponds to one rowGocode, porting is not difficult,GoThe code is also relatively concise. The newGoservices can be provided at the same timeThriftand theRESTfulthe interface. All the effort is worth it, I'm here to compare performance.
|
Python 2.6 |
go 1.0.3 |
load time (minutes: seconds) |
30:00 |
2:40 |
occupy memory |
2.1g |
700m |
A typical calculation service time |