Live data from Hacker News

Writing a very fast cache service with millions of entries in Go

allegro.tech

11–20 of 92 posts

Re: Writing a very fast cache service with millions of entries in Go

#11
"basically everything in Go is built on pointers: structs, slices, even fixed arrays"

As I understand it while that does apply to pointer-to-struct and slices and probably strings, that isn't true for naked structs and naked arrays. Those both behave as value types like int.

Re: Writing a very fast cache service with millions of entries in Go

#12
post #6

So essentially, to meet their requirements, they had to work around the Go garbage collector and use a non-standard HTTP server and JSON parser. Why not just write it in C++?

> Why not just write it in C++?

No need. Someone already wrote Redis.

Re: Writing a very fast cache service with millions of entries in Go

#13
I wonder if I'm missing the point here, but why are Redis or Memcached—implementations of exactly this service which are battle-tested and well-used—not suitable due to "additional time needed on the network", but this service is suitable? Is it just down to the requirement for a HTTP API?

One thing I've noticed is an extreme demand for making internal services available over HTTP. It has it's benefits, but the obvious downsides are the overhead and complexity of HTTP being totally overkill for things like a key-value store of this nature.

Re: Writing a very fast cache service with millions of entries in Go

#14
Why did they have to invent "a very fast cache service with millions of entries"? Are they the first company to ever need one so they had to write it? Can't Redis or Memcached be fast (despite the "additional time needed on the network" — even though Redis uses raw TCP for transactions, while this uses HTTP + JSON)?

As others pointed out, Go is also a very poor choice if you need to work around every part of the language.

Re: Writing a very fast cache service with millions of entries in Go

#15
post #8
post #3

From the article: > [Go] also has managed memory, so it looks safer and easier to use than C/C++. But most of the post describes a sophisticated way to work around the garbage collector, totally reliant on a specific implementation detail of the current Go GC (skipping of pointer-free data types), documented in a GitHub issue. It seems easier to not have, or to not use, the GC in the first place for this specific pro…

Maybe this type of program is better suited for a language like Rust. However, while not having a GC, you have to take care of all memory issues in a way that you convince the compiler that your won't ever blow up. It would be very interesting to have such a comparison, so we could see whether it's easier to work around the GC, or easier to write bullet-proof code with manual memory management. I'd expect the Rust to…

if you understand functional paradigms, rust is actual easier to understand in larger programs

Re: Writing a very fast cache service with millions of entries in Go

#16

Why did they have to invent "a very fast cache service with millions of entries"? Are they the first company to ever need one so they had to write it? Can't Redis or Memcached be fast (despite the "additional time needed on the network" — even though Redis uses raw TCP for transactions, while this uses HTTP + JSON)? As others pointed out, Go is also a very poor choice if you need to work around every part of the lang…

Probably because they wanted full control and understanding of the source code. Large companies often prefer to develop things in-house, even if there already exist good alternatives.

Re: Writing a very fast cache service with millions of entries in Go

#17
Straightforward, simple functionality, extremere perfomance requirements and avertion to allocations and GC?

That sounds like model use case for good old C. I love Go and currently am actively learning it, but why take a memory-safe, GC language and then build your own ad-hoc memory management on top of it to avoid it?

Re: Writing a very fast cache service with millions of entries in Go

#18

I wonder if I'm missing the point here, but why are Redis or Memcached—implementations of exactly this service which are battle-tested and well-used—not suitable due to "additional time needed on the network", but this service is suitable? Is it just down to the requirement for a HTTP API? One thing I've noticed is an extreme demand for making internal services available over HTTP. It has it's benefits, but the obvio…

Agreed. Redis is much faster out of the box with minimal tuning than this solution.

Re: Writing a very fast cache service with millions of entries in Go

#19

I wonder if I'm missing the point here, but why are Redis or Memcached—implementations of exactly this service which are battle-tested and well-used—not suitable due to "additional time needed on the network", but this service is suitable? Is it just down to the requirement for a HTTP API? One thing I've noticed is an extreme demand for making internal services available over HTTP. It has it's benefits, but the obvio…

[deleted]

Re: Writing a very fast cache service with millions of entries in Go

#20

Straightforward, simple functionality, extremere perfomance requirements and avertion to allocations and GC? That sounds like model use case for good old C. I love Go and currently am actively learning it, but why take a memory-safe, GC language and then build your own ad-hoc memory management on top of it to avoid it?

This is probably why the creators of memcached and redis chose C.
Post reply on HN