Category Archives: Programming

PgBouncer and prepared statements

In our system, we use connection pooler called PgBouncer as a proxy to PostgreSQL server. PgBouncer has two main modes Session pooling mode This mode is less performant (it’s a default mode). When a client connects, a server connection will be assigned to it for the whole duration it stays connected. So it does not …

Read more

Golang: testing http and grpc servers

HTTP server is quite easy to test — here is a nice video about it:

Count lines in git repository

https://stackoverflow.com/questions/4822471/count-number-of-lines-in-a-git-repository

Algorithms to find fastest route through network

This is a great article on that — https://www.redblobgames.com/pathfinding/a-star/introduction.html (in russain). It tells about Dijkstra, Breadth-first, Greedy and A* algorithms. It’s all about optimization of one travel. To optimize your entire network you should try to use Aint Colony algorithm — http://rain.ifmo.ru/cat/data/theory/unsorted/ant-algo-2006/article.pdf (it’s in russian). Another link to this PDF file — aca

How go code is being compiled to assembler code

https://go.godbolt.org/z/31FyJ3 I was interested in comparing line 15 vs line 17 of the following code:

E2E tests in go

I tried it via ginkgo and gomega. It has Agouti with WebDriver support out of the box, but I didn’t use it as we have grpc API. That’s the example (table tests):

ORM for go

https://github.com/Masterminds/squirrel Never used it as we always write SQL queries manually. But looks okay for ORM (well, actually a query-builder).

How to make grpc call from shell

1 https://github.com/grpc/grpc/blob/master/doc/command_line_tool.md

2 https://github.com/fullstorydev/grpcurl

How to analyze the performance of your go application in production

You should definitely use chi’s middleware for running pprof and stuff in your admin panel. That’s the repo — https://github.com/go-chi/chi That’s the profiler — https://github.com/go-chi/chi/blob/master/middleware/profiler.go CPU profiling After that you can run something like this in shell:

Or just open it in the browser:

If it opens something different then your browser (sublime …

Read more

Using GOPROXY with go mod