The Go highlights of 2019

It’s been another busy year for our favourite Gopher and to close out the year, we’ve taken a look at the data from the popular Golang Weekly newsletter.

The email newsletter is read by over 29,000 developers — here’s a look at what they clicked on in 2019…

https://superhighway.dev/go-2019

Make resilient Go net/http servers using timeouts, deadlines and context cancellation

When it comes to timeouts, there are two types of people: those who know how tricky they can be, and those who are yet to find out.

As tricky as they are, timeouts are a reality in the connected world we live in. As I am writing this, on the other side of the table, two persons are typing on their smartphones, probably chatting to people very far from them. All made possible because of networks.

Networks and all their intricacies are here to stay, and we, who write servers for the web, have to know how to use them efficiently and guard against their deficiencies.

Without further ado, let’s look at timeouts and how they affect our net/http servers.

https://ieftimov.com/post/make-resilient-golang-net-http-servers-using-timeouts-deadlines-context-cancellation/

Microservices in Golang

Getting started, gRPC: https://ewanvalentine.io/microservices-in-golang-part-1/
Docker and micro: https://ewanvalentine.io/microservices-in-golang-part-2/
Docker compose and datastores: https://ewanvalentine.io/microservices-in-golang-part-3/
Authentication and JWT: https://ewanvalentine.io/microservices-in-golang-part-4/
Event brokering: https://ewanvalentine.io/microservices-in-golang-part-5/
Web Clients: https://ewanvalentine.io/microservices-in-golang-part-6/
Terraform: https://ewanvalentine.io/microservices-in-golang-part-7/
Kubernetes: https://ewanvalentine.io/microservices-in-golang-part-8/
CircleCI: https://ewanvalentine.io/microservices-in-golang-part-9/
Summary: https://ewanvalentine.io/microservices-in-golang-part-10/

 

Go: g0, Special Goroutine

All the goroutines created in Go are under the management of an internal scheduler. The Go scheduler tries to give running time to all goroutines and keep all CPU busy with running goroutines when the current ones are blocked or terminated. It actually runs as a special goroutine.

Scheduling goroutine

Go limits the number of OS thread running thanks to GOMAXPROCS variable simultaneously. That means Go has to schedule and manage goroutines on each of the running threads. This role is delegated to a special goroutine, called g0, that is the first goroutine created for each OS thread:

Then, it will schedule ready goroutines to run on the threads.

https://medium.com/a-journey-with-go/go-g0-special-goroutine-8c778c6704d8

Building a BitTorrent client from the ground up in Go

BitTorrent is a protocol for downloading and distributing files across the Internet. In contrast with the traditional client/server relationship, in which downloaders connect to a central server (for example: watching a movie on Netflix, or loading the web page you’re reading now), participants in the BitTorrent network, called peers, download pieces of files from each other—this is what makes it a peer-to-peer protocol. We’ll investigate how this works, and build our own client that can find peers and exchange data between them.

diagram showing the difference between client/server (all clients connecting to one server) and peer-to-peer (peers connecting to each other) relationships

The protocol evolved organically over the past 20 years, and various people and organizations added extensions for features like encryption, private torrents, and new ways of finding peers. We’ll be implementing the original spec from 2001 to keep this a weekend-sized project.

https://blog.jse.li/posts/torrent/

HTTP APIs is a new flavor of API Gateway. Build low-latency & cost-effective REST APIs

Announcing the API Gateway HTTP API

We talk to customers every day that use API Gateway for critical production applications. This includes everything ranging from simple HTTP proxies to full-blown API management with request transformation, authentication, and validation. API Gateway supports REST APIs and WebSocket APIs, but customers have told us they want more features, lower latency, and lower cost.

Customers have explained their need for the core features of API Gateway at a lower price along with an easier developer experience. Based on this feedback, we are excited to announce the availability of HTTP APIs (Preview).

HTTP APIs is a new flavor of API Gateway. It focuses on delivering enhanced features, improved performance, and an easier developer experience for customers building with API Gateway. Today, we’re launching the first phase, and we will continue to enhance HTTP APIs over the next few months.

We are introducing a new pricing model for HTTP APIs that better represents customer usage patterns. Staying true to our serverless principles, you will only pay for the requests you receive.  With existing REST APIs, you pay $3.50/million requests plus data transferred out.

With HTTP APIs, we have reduced request pricing to $1.00/million requests for the first 300 million requests, and $0.90/million for all requests after that. Most customers will see an average cost saving up to 70%, when compared to API Gateway REST APIs. In addition, you will see significant performance improvements in the API Gateway service overhead.

https://go.aws/2FbVBoG