News for hackers. Stuff that matters.
Re:My £4 a month server can handle 4.2M requests a day by blacklion on Tuesday September 07, 2021 @05:59PM (#28450463)
Crypto markets are very small :-)

I'm working and company which process "real" exchanges, like NASDAQ, LSE, and, especially, OPRA feed.

We've added 20+ crypto exchanges in our portfolio this year, and all of them are processed on one old server which is unable to process NASDAQ Total View in real-time anymore.

On the other hand, whole OPRA feed (more than 5Gbit/s or 65B/day, yes, it is billions, messages of very optimized binary protocol, not this crappy JSON) is processed by our code on one modern server. Nothing special, two sockets of Intel Xeons (not even Platinums).

Re:My £4 a month server can handle 4.2M requests a day by Foomf on Tuesday September 07, 2021 @07:25PM (#28451062)
I've read your few posts a few times and I'm still not sure why you made your post. You're telling the person that you handle more data than them and thus need more resources than them. Was your goal to smugly belittle them? It's not like they said any problem can be solved on their specific resources.
Re:My £4 a month server can handle 4.2M requests a day by blacklion on Tuesday September 07, 2021 @07:39PM (#28451174)
Nope, I want to say, that even much more data could be processed on very limited hardware, and that it is additional confirmation that current hardware is immensely powerful and very under-estimated.
Re:My £4 a month server can handle 4.2M requests a day by Cthulhu_ on Wednesday September 08, 2021 @04:50AM (#28454687)
And that go-to solutions / golden hammers like REST / JSON are very much suboptimal.

I mean I'm still going to use it for client/server communication and the like because I don't have serious performance constraints enough to warrant something that will be more difficult to develop for etc, but still.

Re:My £4 a month server can handle 4.2M requests a day by Aeolun on Tuesday September 07, 2021 @07:30PM (#28451111)
I feel like he’s saying two things.

One, that he’s surprised by how small crypto markets are.

Two, that this one server (or very few server processing) thing scales quite well to billions of messages a day.

I didn’t find any element of smugness here, but maybe I misread the tone.

Re:My £4 a month server can handle 4.2M requests a day by lost-found on Tuesday September 07, 2021 @07:38PM (#28451169)
They are just pointing out the size of crypto market data vs normal market data. I found it interesting, not their fault you didn’t.
Re:My £4 a month server can handle 4.2M requests a day by nostrademons on Tuesday September 07, 2021 @08:19PM (#28451436)
I'd initially responded, but I found that my response had an element of a pissing match over whose data is bigger, so I deleted it.

The thing is - when two engineers get smug, oftentimes lots of fairly interesting technical details get exchanged, so such discussions aren't really useless to bystanders.

Re:My £4 a month server can handle 4.2M requests a day by secondcoming on Tuesday September 07, 2021 @08:22PM (#28451463)
It depends on what your server does with each request though; '65B a day' means little. If all it does is write it to a log then I'm surprised you're not using a rPI.
Re:My £4 a month server can handle 4.2M requests a day by joering2 on Tuesday September 07, 2021 @06:13PM (#28450565)
Could you share some more about that very optimized binary protocol? I know there are ways to be more efficient than JSON but since you call it crappy, your solution must be much much better. Honestly interested to readup more.
Re:My £4 a month server can handle 4.2M requests a day by blacklion on Tuesday September 07, 2021 @06:50PM (#28450839)
It is not "our" protocol, it is protocol designed by exchange and we need to support it, as we can not change it :). Simple binary messages, with binary encoded numbers, etc. No string parsing, no syntax, nothing like this, only bytes and offsets. Think about TCP header, for example.

JSON is very inefficient both in bytes (32 bit price is 4 bytes in binary and could be 7+ bytes as string, think "1299.99" for example) and CPU: to parse "1299.99" you need burn a lot of cycles, and if it is number of cents stored as native 4-byte number you need 3 shifts and 4 binary ors at most, if you need to change endianness, and in most cases it is simple memory copy of 4 bytes, 1-2 CPU cycle.

When you have binary protocol, you could skip fields which you are not interested in as simple as "offset = offset + <filed-size>" (where <filed-size> is compile-time constant!) and in JSON you need to parse whole thing anyway.

Difference between converting binary packet to internal data structure and parsing JSON with same data to same structure could be ten-fold easily, and you need to be very creative to parse JSON without additional memory allocations (it is possible, but code becomes very dirty and fragile), and memory allocation and/or deallocation costs a lot, both in GC languages and languages with manual memory management.

Re:My £4 a month server can handle 4.2M requests a day by localhost on Tuesday September 07, 2021 @10:54PM (#28452493)
Curious if the binary protocol uses floating point or a fixed point representation? Or is floating point with its rounding issues sufficient for the protocol's needs?
Re:My £4 a month server can handle 4.2M requests a day by andylynch on Wednesday September 08, 2021 @04:41AM (#28454626)
No GP but familiar with these protocols. They use fixed point extensively; I can't even thing of an exchange protocol which would use floating point since the rounding issues would cause unnecessary and expensive problems.

This is typical (from NASDAQ http://www.nasdaqtrader.com/content/technicalsupport/specifi... ):

Prices are integer fields. When converted to a decimal format, prices are in fixed point format with 6 whole number places followed by 4 decimal digits. The maximum price in OUCH 4.2 is $199,999.9900 (decimal, 7735939C hex). When entering market orders for a cross, use the special price of $214,748.3647 (decimal, 7FFFFFFF hex).

Re:My £4 a month server can handle 4.2M requests a day by mschuster91 on Wednesday September 08, 2021 @05:39AM (#28454965)
> The maximum price in OUCH 4.2 is $199,999.9900

For NASDAQ it seems to have been something around 430k / share... Buffett's BRK shares threatened to hit that limit a couple months ago: https://news.ycombinator.com/item?id=27044044

Re:My £4 a month server can handle 4.2M requests a day by nly on Wednesday September 08, 2021 @08:56AM (#28456303)
Many exchanges use floating point, even I the Nasdaq technology stack.

X-Stream feeds do for example

Re:My £4 a month server can handle 4.2M requests a day by blacklion on Thursday September 09, 2021 @11:29AM (#28470763)
Most of them use decimal fixed point. Sometimes exponent (decimal, not binary one!) is fixed per-protocol, sometimes per-instrument and sometimes per-message, it depends on exchange.
Re:My £4 a month server can handle 4.2M requests a day by joering2 on Tuesday September 07, 2021 @09:20PM (#28451863)
Thanks for the writeup!
Re:My £4 a month server can handle 4.2M requests a day by nostrademons on Tuesday September 07, 2021 @06:22PM (#28450640)
Some Googling turned up this protocol descriptor:

https://uploads-ssl.webflow.com/5ba40927ac854d8c97bc92d7/5bf...

If you're optimizing for latency JSON is pretty terrible, but most people who use it are optimizing for interoperability and ease of development. It works just fine for that, and you can recover decent bandwidth just by compressing it.

Re:My £4 a month server can handle 4.2M requests a day by paraph1n on Tuesday September 07, 2021 @06:18PM (#28450603)
There are many binary encoding protocols. A popular one is protobufs[1], which is used by gRPC.

[1]: https://developers.google.com/protocol-buffers

Re:My £4 a month server can handle 4.2M requests a day by blacklion on Tuesday September 07, 2021 @07:04PM (#28450935)
"old skool" exchanges uses either FIX (old and really vernose), FAST (binary encoding for FIX) or custom fixed-layout protocols.

Most big USA exchanges uses custom fixed-layout protocols, where each message is described in documentation, but not in machine-readable way. European ones still use FAST.

I didn't seen FIX in the wild for data feeds, but it is used for brokers, to submit orders to exchange (our company didn't do this part, we only consume feeds).

I don't know why, but all Crypto Exchanges use JSON, not protobufs or something like this, and didn't publish any formal schemes.

Fun fact: one crypto exchange put GZIP'ed and base64'ed JSON data into JSON which pushed to websocket, to save bandwidth. IMHO, it is peak of bad design.

Re:My £4 a month server can handle 4.2M requests a day by blibble on Tuesday September 07, 2021 @07:11PM (#28450985)
there's still ascii FIX floating around on the market data side for a few esoteric venues

FAST is not particularly common in Europe

the large European venues use fixed-width binary encoding (LSE group, Euronext, CBOE Europe)

Re:My £4 a month server can handle 4.2M requests a day by blacklion on Tuesday September 07, 2021 @07:36PM (#28451152)
Eurex uses FAST for sure, but I can be wrong about "common".
Re:My £4 a month server can handle 4.2M requests a day by gpderetta on Tuesday September 07, 2021 @08:26PM (#28451484)
Eurex/XETRA EOBI no longer uses FAST. It is about 8 year old t this point, but IIRC some products are still on the older protocol.
Re:My £4 a month server can handle 4.2M requests a day by nly on Wednesday September 08, 2021 @08:58AM (#28456325)
Euronext uses SBE specifically.
Re:My £4 a month server can handle 4.2M requests a day by rewq4321 on Tuesday September 07, 2021 @06:38PM (#28450756)
And msgpack if you want an order of magnitude faster serialization/deserialisation and can put up with worse compression (I think mainly due to schema overhead since protobuf files don't store the schema?)

https://msgpack.org/index.html

Good protobuf vs msgpack comparison: https://medium.com/@hugovs/the-need-for-speed-experimenting-...

Re:My £4 a month server can handle 4.2M requests a day by wffurr on Tuesday September 07, 2021 @06:21PM (#28450621)
Re:My £4 a month server can handle 4.2M requests a day by andylynch on Wednesday September 08, 2021 @04:50AM (#28454690)
Have a look at NASDAQ ITCH, OUCH, and RASH (these are the real names, the story I heard is the original author of didn't like the usual corporate style brand names and wanted certain people to squirm when talking about them).