Two-year summary of using the Go language in a build environment

Source: Internet
Author: User
Tags benchmark install go
This is a creation in Article, where the information may have evolved or changed.

After two years of using the go language in the iron.io production environment, I want to share our experience and feelings. We were one of the first companies to use go in a production environment, and for a long time we didn't know what to expect, but so far, it was great.

In a previous article I talked about switching from Ruby to go , but this time it will be more detailed, and we like the language and what we learned along the course. The introduction does not have a specific order, as follows:

    • Performance (performance)
    • Memory consumption
    • Concurrency (Concurrency)
    • Reliability (Reliability)
    • Deployment (Deployment)
    • Talent (Talent)

Performance features

When we first decided what language to use, we did some research to create simulations for our application environment, Message Queuing. I used go to write a copy of my favorite beanstalkd implementation, using the BEANSTALKD protocol so that I can use the existing client tests. Go is a good performance, almost the same as the official C language (and surprisingly easy to write).

You can find a comparison of go and other language benchmarks in the computer language benchmark game Web site. The following figure is the result of comparisons with Java, which is probably the language we should use when the go language does not exist:



more

Just for fun, In the end, there is a difference between C and go and Ruby, which is even more insane in terms of performance and memory usage.

 


more  

Memory consumption

Go doesn't need to load a virtual machine or interpreter, so it starts fast and small. Ironmq starts with ~ 6444 KB of memory, which also includes loading configurations, establishing connections, and so on. When it runs for a while, memory usage increases because it increases the cache, and so on. Now, our production server runtime memory occupies ~400 MB (which I think is irrelevant, depending on your application).

For two years, we have never experienced memory leaks or other memory-related issues.

Concurrency (Concurrency)

Concurrency is an important part of go, but high-level structure makes it easy to use. I've been using Java for many years and it's comfortable to use the java.util.concurrency package, which is a good concurrency tool, but it's not as easy to use as go on the bottom-up implementation. Go uses goroutines for concurrent operations, and uses channels to communicate between them. Goroutines is very interesting:

"Goroutines is part of the making concurrency easy-to-use. The idea, which have been around for a while, are to multiplex independently executing functions-coroutines-onto a set of th Reads. When a coroutine blocks, such as by calling a blocking system call, the run-time automatically moves other coroutines on t He same operating system thread to a different, runnable thread so they won ' t is blocked. The programmer sees none of this, which are the point. The result, which we call Goroutines, can is very cheap:unless they spend a lot of time in long-running system calls, the Y cost little more than the memory for the stack, which is just a few kilobytes. To make the stacks small, Go ' s run-time uses segmented stacks. A newly minted goroutine is given a few kilobytes, which are almost always enough. When it isn ' t, the Run-time allocates (and frees) extension segments automatically. The overhead averages about three cheap instructions per function call. It is practical to create hundreds of ThousanDS of Goroutines in the same address space. If Goroutines were just threads, system resources would run out at a much smaller number. "  Source
One thing we had to does here is limit concurrency to make sure we didn ' t overload our database or other services Durin G spikes. We do this with a simple semaphore using Go channels.

reliability

The reliability of the language is hard to quantify, but we find our go application very powerful. We have encountered some failures/crashes but because of some external problems (read: Database or some poorly designed library). Generally speaking, there are a lot of high quality go open source libraries now. We have not found memory leaks and significant core library errors.

I even found that our code was high quality because it was written in go. I don't know why, but I feel warm and supple when I write something with go. Perhaps it is a very strict compiler and even forces us to delete useless references and variables. Perhaps it is a language that accomplishes more with a small amount of code. In the future I will find something similar and write them out.

deployment

go will compile all the source code into a single static linked file, so the deployment is very simple, just upload the file and then start it can, no dependencies. There is no run-time dependency. You do not need to install go on the server. and compiled binary is very small, ironmq binary file about 6MB

rollback

If you run a problem after the deployment is complete and you need to roll back to the previous program, just close the wrong program and rerun the previous program. After the program is compiled into a single binary, there is no need to worry about dependency issues after the upgrade.

gifted

When we took a big risk of choosing go, Go was not known to many people, and it was seldom heard. We were the first company to send a go job to the go language enthusiast mailing list , and we were surprised by the applicant's quality of application. We received a job application in China, there are some leading technology companies with extraordinary experience in the developer, there are doctors working on some core projects. Most do not use go for full-time programming, but work very go and passing on their experience and knowledge. I'm not sure what we're trying to build is important, but they want to work with go.

Our first go-hire is a go core developer,  evan Shaw , he's been with us now.

Summarize

After two years of using go to work I can confidently say that we have made the right choice. If we start Iron.io now, go is a choice that you don't have to think about. Many other companies are now using go, including Heroku, Google and people I've said go to have similar opinions. Rob Pike, a go creator, says:

" we realized that the software we built on Google used the language we already have and that it wasn't exactly as envisioned," Pike said in 2011.  "Robert Griesemer, Ken Thompson and I decided to create a language to write the kind of program Google needs. "
Derek Collison,ApceraFounder of the recentWired's articlesaid:
" does the new technology's management and infrastructure tiers provide this cloud delivery model?" "He said so on the wired."  "Within two years, most of it will be written in go. "

Is go the next generation of languages we've been waiting for? This one is too early to say, but it is undoubtedly a good starting point.

All translations in this article are for learning and communication purposes only, please be sure to indicate the translator, source, and link to this article.
Our translation work is guided by CC Protocol, if our work violates your rights and interests, please contact us promptly.
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.