Skip to content
Branch: master
Find file History
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
..
Failed to load latest commit information.
api
go
test
Dockerfile
README.md
main.go
pprof001.png
pprof001.svg

README.md

Go API Server for newsfeed

Overview

This folder contains a golang implementation of the news feed microservice. I used this code as the basis for my evaluation of Go as documented in this blog about Writing Microservices in Go.

I started by using the go-server template from the swagger-codegen project.

Dependencies

I used the following projects.

The go-server templates use mux as the request dispatcher.

Access to the feed MySql DB was via the standard golang SQL API to this MySql driver.

The Redis cache was used to front access to the MySql DB with this Redis client library.

I used the standard Cassandra client library for inbound and outbound entities.

I used this non-standard Elasticsearch client library because it still supports version 2.

Usage

You will need to install the dependencies.

 go get -u github.com/gorilla/mux
 go get -u github.com/go-sql-driver/mysql
 go get -u github.com/go-redis/redis
 go get -u github.com/gocql/gocql
 go get -u github.com/google/uuid
 go get -u gopkg.in/olivere/elastic.v3

Here is how to run the sample unit test

go test test/api_outbound_test.go

Here is how to build the docker image.

docker build -t feed9:1.0 .

Here is how to deploy the docker image.

cd ../k8s
kubectl create -f feed9-deployment.yaml

Load Testing

I tested this microservice using the standard load test environment for two hours (see the client/load folder in this repo). The average per minute throughput of output posts was 18,425 with an average duration of 5 ms, a median of 4 ms, and a 99th percentile of 29 ms.

Here is a CPU profile of the service while running under the above mentioned load test.

You can’t perform that action at this time.