TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Ask HN: Is KDB a sane choice for a datalake in 2024?

40 pointsby sonthonax12 months ago
Pardon the vague question, but KDB is very much institutional knowledge hidden from the outside world. People have built their livelihoods around it and use it as a hammer for all sorts of nails.<p>It&#x27;s also extremely expensive and written in a language with origins so obtuse that it&#x27;s progenitor APL needed a custom keyboard laden with mathematical symbols.<p>Within my firm, it&#x27;s very hard to get an outside perspective, the KDB developers are true believers in KDB, but they they obviously don&#x27;t want to be professionally replaced. So I&#x27;m asking the more forward leaning HN.<p>One nail in my job, is KDB as a data-lake and I&#x27;m being driven nuts by it. I write code in Rust that prices options. There&#x27;s a lot of complex code involved in this, I use a mix of numeric simulations to calculate greeks and somewhat lengthy analytical formulas.<p>The data that I save to KDB is quite raw, I save the market data and derived volatility surfaces, which are themselves complex-ish models needing some carefully unit-tested code to convert in to implied vols.<p>Right now my desk has no proper tooling for backtesting that uses our own data. And I&#x27;m constantly being asked to do something about it, and I don&#x27;t know what to do!<p>I&#x27;m 99% sure KDB is the wrong tool for the job, because of three things:<p>- It&#x27;s not horizontally scalable. A divide and conquer algo on N&lt;{small_number} cores is pointless.<p>- I&#x27;m scared to do queries that return a lot of data. It&#x27;s non trivial to get a day&#x27;s worth of data. The query will just often freeze, it doesn&#x27;t even buffer. Even if I&#x27;m just trying to fetch what should be a logical partition, the wire format is really inefficient and uncompressed. I feel like I need to engineering work for trivial things.<p>- The main thing is that I need to do complex math to convert my raw data, order-books and vol-surfaces into useful data to backtest.<p>I have no idea how do do any of this in KDB. My firm is primarily a spot desk, and while I respect my colleagues, their answer is:<p>&gt; Other firms are really invested in KDB and use KDB for this, just figure it out.<p>I&#x27;m going nuts because I&#x27;m under the assumption that these other firms are way larger and have teams of KDB-quants doing the actual research. While we have some quant traders who know a bit of KDB but they work in the spot side with far more simple math.<p>I keep on advocating for some Parquet style data-store with Spark&#x2F;Dask&#x2F;Arrow&#x2F;Polars running on top of it that can be horizontally scaled and most importantly, with Polars, I can write my backtests in Rust and leverage the libraries I&#x27;ve already written.<p>I get shot down with &quot;we use KDB here&quot;. I just don&#x27;t know how I can deliver a maintainable solution to my traders with this current infrastructure. Bizarrely, and this is a financial firm, no one in a team of ~100 devs has ever touched Spark style tech other than me here.<p>What should I do? Are my concerns overblown? Am I misunderstanding the power of KDB?

15 comments

vessenes12 months ago
Long time Kdb&#x2F;q enthusiast, absolutely NO enterprise deployment experience whatsoever.<p>This feels like a ‘pick your poison’ situation. You’ve been told already you won’t be allowed to dump kdb; it’s probably embedded in your infra in a bunch of ways, and ripping it out is a no-go.<p>OK, so, you have data in kdb. What you’re doing right now (it sounds like) is using it as literally just a raw data store. That’s the worst way to use it; a lot of work went into making it very fast to run summarization&#x2F;grouping&#x2F;sorting&#x2F;etc all right on the kdb servers. Note that this is very unlike how an Apache project works.<p>Unfortunately, you wrote a rust library that probably doesn’t really distinguish your kdb storage from, say, JSON files, so you are at a crossroads.<p>Option 1: Get some good data cloning up, clone data over to your preferred generalized data lake tech, run rust against it.<p>Option 2: Go through your rust code with a fine tooth comb and figure where exactly it’s doing things that cannot be done semantically in q&#x2F;k. Start slimming down your Rust lib, or more exactly, rework what queries its sending, and what state of data it expects<p>Option 3: dump your rust library and rewrite it in q or k.<p>Of these, I would be willing to bet that for an ‘ideal’ developer, meaning a 160+ IQ dev skilled in Rust, vs a 160+ IQ dev skilled in kdb, vs a 160+IQ dev skilled in say Java + Spark, Option 3 is going to be by far the least resource intensive in terms of deployed hardware, and the fastest &#x2F; lowest latency.<p>That said, given where you’re at, a principled Rustacean who’s looking at coming to grips with kdb realtime, I think I’d recommend you think hard about Option 2. By the end of Option 2, you will probably be like “Yeah, this could be all k, or nearly all,” but you’re likely going to have some learning to do.<p>Think of it this way, when you’re done, you’ll be on the other side of the cabal, and can double your base rate for your next gig. :)
alexpotato12 months ago
I&#x27;m speaking as someone who:<p>- has worked in finance for both hedge funds and banks<p>- has managed a project where KDB was mandated to be used by mgmt.<p>- on the above project, tasked one of the smartest developers I&#x27;ve ever worked with as the person to learn KDB and use it in the application<p>- I&#x27;m a SRE (and former Operations) so that colors my perspective.<p>Given the above, I list out the pros and cons:<p>PROS<p>- KDB is pretty fast (on some metrics of fast)<p>CONS<p>- VERY few people can write&#x2F;read good Q (compared to say people who know Pandas&#x2F;SKlearn etc)<p>- The learning curve is INCREDIBLY steep. Even the most cited documentation and tutorials have something like this in the intro &quot;are you really sure you need KDB? B&#x2F;c Q is REALLY hard to learn&quot;<p>- As you mention, open source industry standards have come a LONG way since it made sense to have KDB (e.g. in the late 2000s&#x2F;early 2010s)<p>Conclusion:<p>If you have a lot of in house expertise, then sure, it probably makes sense. If you are starting from scratch, I would not recommend it.<p>On that note, this point stood out: &gt; People have built their livelihoods around it and use it as a hammer for all sorts of nails.<p>If you work in the industry long enough, you will find a lot of complexity added to systems for three reasons:<p>1. Some things in finance really do need to be complex due to the math etc<p>2. Smart people with quant backgrounds tend to LOVE complex things.<p>3. Smart, rational people realize that adding complexity is one way to build a fortress around their job. This is particularly true in high paying firms where people realize that it&#x27;s their knowledge of the complex systems that is keeps them in that high paying job.<p>Give that, if you are looking to make a name for yourself at your firm: making things run faster, with fewer issues etc is a good way to stand out. Just be careful that you don&#x27;t eliminate so much complexity that people get mad at you.
steveBK12312 months ago
Longtime KDB user here I think you maybe have some misunderstanding personally and some poor engineering at your firm around the the tech&#x2F;data. Timeseries data particularly market data is exactly the use case the product excels at.<p>The wire format is compressed.<p>KDB horizontally scales (even their competitors comparison pages state this - <a href="https:&#x2F;&#x2F;www.influxdata.com&#x2F;comparison&#x2F;kdb-vs-tsdb&#x2F;" rel="nofollow">https:&#x2F;&#x2F;www.influxdata.com&#x2F;comparison&#x2F;kdb-vs-tsdb&#x2F;</a>)<p>A few things to consider that might help - you do not want a solution (in any language&#x2F;tech) that involves pulling an entire day of market data off disk, across the wire and over to your process for analysis. KDB will not excel for this, nor will anything else. KDB shines when you learn to move your code to the data rather than your data to the code.<p>What does &quot;move the code to the data&quot; mean in practice?<p>You can do things like use PyKX which allows you to run your python &amp; kdb code together on top of the data directly in the same process.<p>You should do as much of the filter&#x2F;aggregation&#x2F;joins&#x2F;etc over on the KDB side before pulling the results back. You should also define, generate and use pre-aggregated data where it makes sense for your use case (second &#x2F; minute &#x2F; day bars).<p>Backtesting in KDB is relatively trivial as you have historical data organized by day and symbol. Any half decent KDB dev should be able to cook one up of increasing complexity for you.<p>Nick Psaris has a couple books that cover more advanced topics that may be of use.
评论 #40626612 未加载
评论 #40631950 未加载
评论 #40626586 未加载
oneplane12 months ago
As powerful as KDB is, finding people to make use of it is almost not worth it. But as it tends to be entrenched (usually via poor reasoning), you usually are screwed when some company or project uses it. I personally would just quit and work somewhere else or on something else.<p>It&#x27;s about as isolated as mainframe engineering; great on paper, great in closed off circles, but practically dead in the tech community at large.
succint11 months ago
You definitely should be able to do these calculations in q near-data. In fact, porting your code from Rust to Q might even reveal bugs and&#x2F;or sub-optimal code. This was many years ago but I ported over some non-trivial image processing code to Q just to learn the language. I was amazed by how everything fit into a page of code and how seeing all of it together revealed a subtle bug and a couple of ways to optimize better.
sonthonax12 months ago
I care about my job, enjoy my work, and I take pride in being able to deliver things, but I don&#x27;t know how to deliver value for my traders here.<p>I&#x27;d really appreciate some perspective from seasoned data-engineers who might have seen this KDB as a data-lake pattern before, and what they did about it. Not just technically, but how they managed the organisational change of KDB for the KDB quants.<p>I also just don&#x27;t really know where else to ask. There&#x27;s not really an online KDB community, and you have a lot of KDB devs who are really good at KDB but know barely anything else which makes me skeptical of their advice.
评论 #40626512 未加载
nextworddev12 months ago
No. Don’t go with KDB. (Source: built multiple production backtesting systems in prop desks)
评论 #40631215 未加载
rbanffy12 months ago
&gt; Pardon the vague question, but KDB is very much institutional knowledge hidden from the outside world.<p>This answers the question for me: unless you are sure the performance lives up to your expectations AND it gives you a competitive advantage (which can be easily lost with the human in the loop), don&#x27;t even think of it. Get the next best tech that&#x27;s easy to use, and well documented, and remove the human in the loop to gain the edge.
steveBK12312 months ago
Also you mention rust - <a href="https:&#x2F;&#x2F;docs.rs&#x2F;kdb&#x2F;latest&#x2F;kdb&#x2F;" rel="nofollow">https:&#x2F;&#x2F;docs.rs&#x2F;kdb&#x2F;latest&#x2F;kdb&#x2F;</a><p>The old style of kdb integration you could compile a .so and load it in to extend the language. Now people use PyKx to load in python modules. I have a guy doing this on my team to load a Python wrapped Rust lib.<p>It looks like you have a few options with Rust as per the link above.<p>Note this allows you to do the &quot;move the code to the data&quot; trick I mentioned.
评论 #40626713 未加载
pyuser58312 months ago
If you’re using KDB, use KDB. The decision has been made, the license paid.<p>Work to change your organization, not your technology.<p>Nuclear bombs used to be controlled by decades old systems that worked off floppy disks. Why? Because the systems were so important people worked around the tech.<p>You’re in a similar spot.<p>Even when using conventional languages and platforms, sometimes the decision has been made and you’re stuck with it.<p>KDB might not be the best fit for a datalake, but plenty of people will sleep better just knowing it’s KDB.<p>Change the people, not the tech.
评论 #40626454 未加载
sneakyavacado12 months ago
I’ve intermittently worked with kdb for the past three years and feel broadly the same.<p>Can you deploy to a host that has a mount of the database and run a local q or are you forced to query via ipc? Are you on cloud or on prem?<p>A fight for horizontal scaling and running a local q against the data might be an easier one to win than a full replacement of the database.
gigatexal12 months ago
Totally out of the loop here, what&#x27;s KDB?
评论 #40626392 未加载
评论 #40626715 未加载
评论 #40627085 未加载
评论 #40626609 未加载
mrj12 months ago
<p><pre><code> I get shot down with &quot;we use KDB here&quot; </code></pre> Well, so fundamentally a decision has been made already. You got shot down. Unless there&#x27;s some significant new data that might change that decision, it is what it is. The next step is for you to decide if you can get on board with that, or if it&#x27;s time to start planning your next move. I don&#x27;t know anything about KDB and you might be right. But it sounds like the powers that be don&#x27;t want to make this change.<p>Sorry, but it makes no sense to swim against the tide in an organization where you don&#x27;t have the rank to make the decisions.<p><pre><code> I keep on advocating for some Parquet style data-store... </code></pre> The worst thing you can do is to continue spending your time advocating for change, they&#x27;ve heard you. If you stay on and the current tech does become untenable, you are unlikely to be the hero even in that case. They might just remember you as the detractor.
评论 #40626537 未加载
jmakov12 months ago
What&#x27;s wrong with delta lake?
评论 #40626084 未加载
michaelg7x12 months ago
Hi, KDB is used for this kind of thing in probably all the Tier 1 banks, or has been at some point. I&#x27;m surprised that you seem to have been given so little help by the KDB guys as it really matters how you store your data. That&#x27;s informed by the data itself and the access patterns you&#x27;re likely to use. When you say you&#x27;re saving them as complex-ish models it makes me think that it may not be optimal for KDB to process.<p>KDB is in some respects as dumb as a bag of rocks. There is no execution profiler nor explain plan, no query analysis at all. When running your query over tabular data it simply applies the where-clause constraints in-order, passing the boolean vector result from one to the next, which refines the rows still under active consideration. It&#x27;s for this reason that newbies are always told to put the date-constraint first, or they&#x27;ll try to load the entire history (typically VOD.L) into memory.<p>KDB really is very fast at processing vector data. Writing nested vectors or dictionaries to individual cells could easily be slowing you down; I&#x27;ve heard of one approach which writes nested dictionaries into vectors with the addition of a column to contain the dictionary keys. Then you get KDB to go faster over the 1-D data, nicely laid out on disk. You really do need to write it down in a way that is sympathetic to the way you will eventually process it.<p>You can create hashmap indices over column data but the typical way of writing down equity L1 data is to &quot;partition by date&quot; (write it into a date directory) and &quot;apply the parted attribute&quot; to the symbol column (group by symbol, sort by time ascending). Each of the remaining vectors (time, price, size, exchange, whatnot) are obviously sorted to match and finding the next or previous trade for a given symbol is O1 simplicity itself. I&#x27;ve never worked on options data and so can&#x27;t opine on the problems it presents, but if you&#x27;ve been asked to write this down without any help, then it&#x27;s pretty &quot;rubbish&quot; of the KDB guys in your firm. You have asked for help, right?<p>I&#x27;m really going on a bit but just a few more things:<p>- KDB will compress IPC data — if it wants to. The data needs to exceed some size-threshold and you must, I think, be sending it between hosts. It won&#x27;t bother compressing it to localhost, at least, according to some wisdom received from one of the guys at Kx, many moons ago. The IPC format itself is more or less a tag-length-value format, and good enough. It evolved to support vectors bigger than INT32_MAX a while ago but most IPC-interop libraries don&#x27;t tend to advertise support for the later version that lets you send silly-big amounts of data around, so my guess is you may not want to load data out of KDB a day at a time. Try to do the processing in KDB!<p>You said you&#x27;re scared to do queries that return a lot of data, and that it often freezes. Are you sure the problem is at the KDB end? This may sound glib but you wouldn&#x27;t be the first person to have been given a VM to do your dev-work on that isn&#x27;t quite up to the job. You can find out the size of the payload you&#x27;re trying to read by running the same query with the &quot;-22!&quot; system call. It&#x27;ll tell you how many bytes it&#x27;s trying to send. Surely there&#x27;s help to be had from the KDB guys if you reach out?<p>- I&#x27;m confused by the use of the term &quot;data lake&quot;: to me this includes unstructured data. I&#x27;m not sure I&#x27;d ever characterise a KDB HDB as such.<p>- If your firm has had KDB for ages there&#x27;s a good chance it&#x27;s big enough to be signed up to one of the research groups who maintain a set of test-suites they will run over a vendor&#x27;s latest hardware offering, letting them claim the crown for the fastest Greeks or something. If your firm is a member you may be able to access the test-suites and look at how the data in the options tests is being written and read, and there are quite a few, I think.<p>- KDB can scale horizontally. It can employ a number (I forget whether it&#x27;s bounded) of slave instances and farm-out work. I think I read that the latest version has a better work-stealing algo. It&#x27;s often about the data, though: if the data for a particular symbol&#x2F;date tuple is on that one server over there, then you&#x27;re probably better off doing big historic-reads on that one server alone. I doubt very much you&#x27;re compute-bound or you&#x27;d have told us that your KDB licence limited you to a single or N (rather than any number) of cores.<p>- Many years ago I was told never to run KDB on NFS. Except Solaris&#x27; NFS. I have no idea whether this is relevant ;)<p>Good luck, sonthonax
评论 #40631359 未加载