137 pointsby tomasol2 hours ago19 comments
  • bitexploder2 hours ago
    I started setting up my workflows using Temporal. It deploys as relatively light weight local app. For an isolated local installation it uses SQLite. It makes the process of dealing with API retries and organizing workflows and tasks really simple. I recommend giving it a try. It is, philosophically, exactly what this article is suggesting, but it adds an incredibly rich and flexible interface for agents to work with. Additionally, the web UI makes it very easy to inspect workflows, review agent execution, etc. Temporal also encodes much higher reliability into your system, almost for free. Distributed and reliable systems are hard, don't reinvent the wheel IMO.

    If you find yourself wanting things like an easy way to then introspect your SQLite database, figure out what is happening in the workflow, compose individual tasks, make workflows trivially callable, etc, give Temporal a look.

    Alongside this, I have mostly moved away from files for agents. Markdown and JSON are great, but also feel like traps when building out smaller local apps. LLMs are great at SQLite and you can render anything you want out of it (Markdown, JSON, etc). It saves a lot of tokens when an agent can just query a specific row instead of having to fire up jq or grep through markdown. You get a nice portable self contained data management system that encourages agents to be more disciplined about how they structure their data than a bunch of files. It also continues to scale into MySQL/Postgres if your little local projects start to outgrow or become more formal, you already have schema and discipline around data.

    • rick1290a minute ago
      Interesting about the files vs db approach. I have been going back and fourth. I landed on db as well.
    • jawns2 hours ago
      Could you give an example of a case where you'd use SQLite instead of jq or grep through Markdown?
      • phamilton17 minutes ago
        My favorite lens on SQLite is that it is actually two things:

        1. A robust durability implementation 2. A library of high performance data structure and algorithms

        The fact this it's SQL is nice, but those two attributes are what make it great.

        For example, I'm implement an in-process event log that I want to be durable. I started simple, but soon saw some edge cases and instead of playing whackamole I just swapped to using sqlite as an ordered kv store that gives me ACID.

        Another example: ingesting multiple inter related datasets. Instead of a dozen hash maps in memory, I load them up into sqlite (no persistence) and then slice and dice as I need to.

        It's a super useful tool.

      • chaps20 minutes ago
        The moment my JSON has any sort of depth and I need to write a parser for it and potentially account for unspecified behavior. JSON's nice when it's nice, but it's terrible when it's terrible. It's 100x easier to write SQL than writing jq and... dear god if I have to use grep -A or -B, I'm doing something wrong. Constraints are actually a good thing!

        The underlying database isn't the most important thing. Just use SQL. Its namespacing (eg, through CTEs) is good and you're more likely to have colleagues who know SQL compared to jq.

      • fragmede42 minutes ago
        Honest answer is: whenever your markdown or json files get to be big enough that grep/jq takes long enough that you get bored waiting for it.
    • peterson_lockan hour ago
      This reads like an advertisement for Temporal :)
  • levkkan hour ago
    I don't understand this obsession with SQLite for real, production apps. SQLite is an embedded database, completely unsuitable for managing concurrency. This is what database _servers_ are for, e.g., Postgres, MySQL, etc. Their entire job is to allow you to modify data from multiple processes, on different machines, at the same time.

    This is a foundational principle of computer science. It seems to me that the "SQLite for everything" crowd is a little bit inexperienced.

    • rpdillona few seconds ago
      Sqlite is good for lots of stuff, but you're probably focusing your days on high-scale webapps that want sharding with networked DBs. That's one domain, and an interesting one, but there are lots of others.

      I'm a big fan of re-evaluating prior "best practices" in light of technology changes, especially in ways that improve simplicity. Running my family's social media site off a single sqlite DB on a VPS is great. ~15 users, almost zero maintenance. I run my FreshRSS instance off of sqlite, as well as my "now" page. At work, I used sqlite for all kinds of things over the past decades: as an ad hoc job queue, as a quick way to ingest and query lots of logs locally, and present/filter in realtime with simonw's excellent https://github.com/simonw/datasette.

      I don't think it's every "sqlite for everything" as much as it is "sqlite in lots of places you probably didn't think to apply it."

      kentonv/Cloudflare's work on sqlite at the edge might have made this thinking a bit more popular, but it was always around. https://blog.cloudflare.com/sqlite-in-durable-objects/

      I suspect being aware of all those little neat cases and wanting to leverage sqlite for them may be an indicator of experience, rather than the opposite.

    • peterspath28 minutes ago
      That’s why there are billions of SQLite databases right?

      SQLite is likely used more than all other database engines combined. Billions and billions of copies of SQLite exist in the wild. SQLite is found in:

      Every Android device Every iPhone and iOS device Every Mac Every Windows 10/11 installation Every Firefox, Chrome, and Safari web browser Every instance of Skype Every instance of iTunes Every Dropbox client Every TurboTax and QuickBooks PHP and Python Most television sets and set-top cable boxes Most automotive multimedia systems Countless millions of other applications

      https://sqlite.org/mostdeployed.html

      • mr_toad22 minutes ago
        That’s a comprehensive list of single user devices.
      • pibaker10 minutes ago
        GP calls out concurrency as a weakness of SQLite. Most of the examples here don't experience the same load even a moderately sized web service experience day to day.

        And no, being a part of the python standard library doesn't means it is being used by the average python user. These days I'd say at least half of them are just there for machine learning.

      • ksd4828 minutes ago
        levkk is talking about concurrency. The list you gave doesn't explain high concurrency requirements for usage.
      • petcat3 minutes ago
        sqlite is great for the contacts app on your phone
    • lanstin30 minutes ago
      I had very good results giving 1 SQL DB per go routine, so the accesses were serialized up front, on a very high volume (130K requests/second) service. Exact transactionality was not a product goal, and the SQLite was just to backup the in memory state. If we lost a little due to abend or something, that was ok (although for normal maintenance it caught SIGTERM and stopped the listen and then waited for in flight calls and then flushed the remaining changes to SQLite; then on startup it would read the SQLite into memory to populate before taking the listen; persistent storage across container runs, and never both reads and writes to the same file at the same time. (It also just closed the DB and opened a new one when it hit some limit of rows, so as not to fill the disk; the max size of the SQLite corresponded to the max size of the LRU map being served from in memory; then it just flipped A / B between "a full memory worth of data stored" and "the currently updating state." A lot easier than having to write out proto bufs to disk or whatever I would have done for transient (during restarts/maintenance) persistence.
    • jph0034 minutes ago
      You seem to have a rather limited understanding of what kinds of concurrency exist and how those needs are best met. Whether something is a server or not is not very relevant to this discussion.

      SQLite is an excellent production db for many real world workloads, as has been widely documented. It is very different to Postgres, so requires learning a whole new skill set.

      One way to think about it is that SQLite can work well for the parts of your system where there is naturally strong partitioning.

    • abtinf23 minutes ago
      There are many cases where SQLite + concurrent front end (like a go net/http server) can handle all the load that a service might ever conceivably have to handle, especially if allowed to scale up hardware over time. You can trivially scale up SQLite to, what, hundreds of thousands of tps?

      The only thing you really give up is HA/failover and DR. But there are solutions to deal with those. And single-server systems are generally surprisingly robust (since, in the absence of very complex control planes, uptime goes down with more systems).

    • bborud34 minutes ago
      Computer science no more get its hands dirty with concrete software than physics primarily being about building bridges.

      It is not «a foundational principle of computer science».

    • teaearlgraycoldan hour ago
      Well if you run a tiny single-threaded app then SQLite is a nice simplification over spinning up a separate machine for Postgres.
      • ai_fry_ur_brain22 minutes ago
        I use postgres for very simple apps. I have a Dockerfile I use in my boilerplate repo. It takes a single make cmd for me to build, start and run migrations. Its as simple as using sqlite.
    • sevenzeroan hour ago
      Isn't concurrency also limited by your machines disk speed for writes, what difference does it make if you write sequentially vs concurrently? Why does concurrency even matter for databases?
      • malisper29 minutes ago
        > Isn't concurrency also limited by your machines disk speed for writes, what difference does it make if you write sequentially vs concurrently? Why does concurrency even matter for databases?

        For a simplified example, having three processes reading blocks X, Y, Z in parallel is much faster than having a single process read block X, wait for the read to finish, read block Y, wait for the read to finish, read block Z and wait for the read to finish.

      • refulgentisan hour ago
        > Isn't concurrency also limited by your machines disk speed for writes

        Yes, in theory: given a large enough database, and a disk that can only do one operation at a time, and a large enough operation that touches enough of the database. In practice, in a SQLite single tenant scenario? No, not at all.

        > what difference does it make if you write sequentially vs concurrently. Why does concurrency even matter for databases?

        As soon as your codebase involves reacting to events independently of a user taking action it becomes a practical concern. Generally, this is a broad question and has 1,000,000 answers.

        EDIT: Originally I had "I think you understand generally, no?" appended but realized that's not helpful at all, if you did, you wouldn't be asking.

        Something that may help is imagining what'd happen if a DB wasn't thread safe / didn't allow multiple writers. Ex. in SQLite's case, it allows multiple write operations to take place but there's a one-at-a-time queue. If we didn't have databases that were able to execute multiple writes simultaneously, you'd need a separate database for each concurrent writer you expect, and you'd effectively have a global lock. Orderly scaling would be ~impossible unless you did something crazy like have a single server per user

        • sevenzero41 minutes ago
          I guess I need to dive deeper into this as I do not understand the implications you gave me, but I appreciate the attempt. Generally I understand why concurrency is good in many cases, I just dont get why its important for database stuff too.

          Edit: thanks for clarifying in the edit, makes a lot more sense.

          • strbeana few seconds ago
            Imagine if every tweet had to go through a one-at-a-time queue before being persisted. There's about 6000 tweets per second, so you would have to be able to save them at <0.17ms per tweet or else you would become backlogged. If you are getting backlogged, you have to buffer those incoming tweets somewhere until they can be writted, and eventually that buffer gets full and you start losing tweets.
    • O3marchnative40 minutes ago
      > This is a foundational principle of computer science

      How exactly is this a foundational principle of computer science?

    • onlyrealcuzzoan hour ago
      It's almost as if Postgres isn't perfect, and one size shoe doesn't fit all.

      Some people want some of the benefits you get from SQLite.

      SQLite is obviously not perfect, but it's an incredible piece of software, and people regularly find good ways to make use of an excellent pieces of software.

    • an hour ago
      undefined
    • BoredPositron15 minutes ago
      I worked on an app that had sqlite databases per user... it was fine.
    • fragmedean hour ago
      So teach them. If you want to bring up computer science fundamentals, the question is where does SQLite sit with regards to the CAP theorem. Consistency, Availability, and Partition tolerance. SQLite isn't a distributed system, so there are no partitions to tolerate, so it's a CA system. Other databases make different tradeoffs. For systems that don't need concurrent writes, SQLite is pretty great! There are no users to manage, no permissions, no daemon to run, no server and port to mix up. Just open a file on disk using a library.
      • refulgentisan hour ago
        Strawman, no? "run an Obelisk server with a SQLite database", now we're distributed.

        SQLite is a nice local store. It's this server stuff that I don’t grok, well, yet. :)

        • fragmede34 minutes ago
          What changed is SSDs. SSDs means that local access is faster than hitting the network. An expensive SAN stopped making sense because of this in specific cases. So for read heavy, or even read only database loads, you copy the SQLite file to the node that's processing the file, and just update that file whenever the data does get changed.
    • doctorpangloss42 minutes ago
      sqlite is more like a file format than a database. it competes with .xlsx.

      > "SQLite for everything" crowd is a little bit inexperienced.

      every time i see it in a real application, it becomes a huge focus of issues (for example: jellyfin, hermes, openwebui, comfyui)

      • fragmede33 minutes ago
        What kind of issues commonly arise?
    • refulgentisan hour ago
      I absolutely 100% do not understand it either. At all. Every time I try to over the last year or two I come away with the conclusion its something that sounds cool (to me too!) but is guaranteed to cause more problems than more obvious solutions.

      That being said I'd kill for someone who used it and benefited to explain it to me in a practical sense. (specifically where syncing is involved, and syncing a subset of the SQLite is necessary. If it's "just" a document store thats treated like a blob for syncing/backup, that's familiar. If it's all in one storage but only local, that's familiar.)

      Re: TFA, I guess it would have helped if I knew what Obelisk was, which is on me, and a more in-depth explanation of how this ties into AI/agents, which is on the industry/writer.

  • stephenlf17 minutes ago
    Can’t wait to see the next iteration of this idea with “Logs are all you need for durable workflows.”
    • gchamonlive11 minutes ago
      Are logs all you need for durable workflows? I'm confused here. How'd persist and query nested or related data over logs? By logs I assume you mean something like elasticsearch or meilisearch?
  • shukantpalan hour ago
    SQLite is surprisingly performant for single node applications even when comparing to Postgres. Postgres consumes a lot more memory and requires IO to hop through IPC whereas you can keep everything in process in SQLite with a shared connection pool.

    I've been testing different storage engines for my agent harness and I can get up to 7.5k concurrent sessions on a single vCPU with SQLite whereas Postgres crashes or runs out connections.

    [0] https://github.com/impalasys/talon/pull/23#issuecomment-4577...

    • bob102936 minutes ago
      When used properly, SQLite is effectively an in-process method invoke. If the only remaining things in the way are your runtime, kernel, file system and a local NVMe storage device, you may find it massively outperforms hosted alternatives.

      Leaving the current thread is where you lose the game in terms of latency. SQLite can work on timescales measured in microseconds if you don't force interthread communication.

    • onlyrealcuzzoan hour ago
      > SQLite is surprisingly performant for single node applications even when comparing to Postgres.

      In the context of SQLite being understood to be a quite excellent piece of software - shouldn't we expect it to be?

      In the context of a single-node, Postgres is overkill. It should not be expected to be competitive with SQLite.

      This is almost like benchmarking an in-memory HashMap to Redis and being surprised that it performs well in ideal conditions.

      • shukantpalan hour ago
        Yes, agreed on SQLite/Postgres. But I'm going to benchmark RocksDB next and see what the performance characteristics are. I suspect the LSM tree storage engine of RocksDB might perform better since agents are so write heavy when running highly concurrent workloads. After all, you are streaming LLM tokens into disk and fanning them out to subscribed clients.
  • golem14an hour ago
    Litestream releases 5.9 and newer have a bug that causes instances to sync an insane amount of data. a DB with <10K of data in it and practically no writes/reads causes something like 10GB of daily replication traffic. For my toy project that got needlessly expensive.
  • Xcelerate2 hours ago
    Haha, I just started doing this on my own. Found it helps the agents preserve state better. I typically ask them to design a DAG first based on a set of specifications and then execute it (each step stores something in a SQLite DB). Iteration is pretty simple then because I just ask for a tweak to one or two steps of the DAG, and then to re-run.

    Funny how people are independently converging on similar patterns of "what works" here. Still feels like we're in the wild west with all these ad-hoc patterns of agent orchestration that people are coming up with.

    • zrail2 minutes ago
      Same. The prompt was essentially, every checkbox in this PLAN.md should be task in SQLite.
  • yokoprimean hour ago
    If you're just doing workflows from a single node, i guess it can be ok as long as theres a single writer. But scaling across multiple servers it clearly is not all you need.
  • kubik3692 hours ago
    Meta comment: This is a domain under my countries TLD (Slovakia) and it is one of the handful of words that are a word with the TLD in my language (and coincidentally) also in English. Every now and then, I will check on the domains with a retrograde dictionary for domains that have this property and root of this particular domain had a roundcube email server on it (can be checked on archive.org). After further checking, the local company actually named themselves Obeli s.r.o. (s.r.o. is Ltd), presumably so that they could use a domain that is a real word when said together with the TLD. (EDIT:) Forgot to write the thing I wanted to mention in the first place: it appears the domain must have lapsed and/or the author bought it from the company that was using it.

    Another fascinating fact: our countries TLD has been stolen Ocean's 11 style (I am not kidding). After Czechoslovakia split into Czech Republic and Slovak Republic, the newly created Slovak .sk TLD has been under the care of people from the local university. The university also had some offices that they were leasing out. Someone had leased this office space (EDIT: this is important as this means they had the same physical address), created a company that had the same name as the NGO that was taking care of the domain, so e.g. the NGO was named "My Company o.z." and the perpetrator created a "My Company s.r.o." (our countries version of the american Ltd). This person then wrote to ICANN to change the address to the "My Company s.r.o." presumably under the pretense that this was just an administrative error and from this point, they have functionally taken custody of the TLD. I was not able to find how they did it technically, but I presume they persuaded ICANN to then point to their servers instead of the real ones. After this happened, it seems that no one noticed for some time. When they noticed, they tried taking it back, but they weren't able to. For some inexplicable reason, the government during that time (Šuster era, early 2000s) gave the new company a contract that was functionally uncancellable from the government side. Later governments made this even more uncancellable and in 2017, then Minister of IT (and as of this day president!) Pellegrini made the contract literally uncancellable. As a result of this, we have one of the most expensive domains around (18e/year, rising each year for no good reason). (EDIT:) The company running our countries TLD is now a foreign entity that the whole thing has been sold to (multiple owners over time) and we as a country have no control over if I understand it correctly.

    I might have gotten some details wrong as I am writing this from my memory of researching it a couple of years back, but you get the idea, crazy stuff. Here is an article in Czech [0] that tells the story a bit better, but you have to translate it.

    [0] https://www.root.cz/clanky/pribeh-domeny-sk-aneb-kradez-za-b...

    // EDIT: I have found that the article actually links the movement to return the TLD back [1]. It also has a story tab [2], so they have something much more precise than the paraphrasing I wrote.

    [1] https://www.nasadomena.sk/

    [2] https://www.nasadomena.sk/historia/

  • 0x59an hour ago
    Big complex data model with ambiguous query patterns? Postgres

    Small, well defined, data model with known query patterns? Bespoke model

    There probably is a place for sqlite and my project space so far hasn't yet well-aligned with it.

    • asdff39 minutes ago
      Probably going to get some winces for this but I do everything with flat files. Maybe my data aren't massive enough, but I mean I can do the relational thing by just having these metadata in some column, and returning rows that contain my desired information in these columns. Even if the file were too big to fit into memory one could just subset chunks of it and chew through. All this can be done with no dependencies, just base libraries of a lot of languages.
  • bze1227 minutes ago
    Isn’t this very similar to cloudflare durable objects & workflows?
  • localhosteran hour ago
    Idk if this article was vibe written or the author just "got adjusted" but it's clearly is, and it's unreadable. Man this becomes anmoying
  • sgloutnikov2 hours ago
    It's close enough that DBOS does support SQLite. [0] The default for prototyping is SQLite, but sure you can run it in production if you wanted.

    Obligatory list of workflow engines and libraries because it's such a common need that a lot have rolled their own. [1]

    [0] https://docs.dbos.dev/python/tutorials/database-connection

    [1] https://github.com/meirwah/awesome-workflow-engines

  • netik41 minutes ago
    Until you scale past one machine…
  • ChrisArchitect40 minutes ago
    Related:

    Building durable workflows on Postgres

    https://news.ycombinator.com/item?id=48313530

  • EGreg2 hours ago
    Files is all you need.

    https://xkcd.com/378/

  • tutamona minute ago
    [dead]
  • orf2 hours ago
    > The caveat is that Litestream replication is asynchronous. A restore can miss the newest local writes if the SQLite volume disappears before they are copied. That is fine for many AI and experimentation workflows

    In short: SQLite is not all you need, unless you’re just experimenting don’t actually care about durability, in which case you also need litestream + object storage.

    Right.

    • gwking2 hours ago
      The suitability of Litestream for production disaster recovery is also an open question in my mind. I used 0.3.x for several years and when I tried to upgrade to the 0.5.x series there were runaway disk usage problems that would have caused downtime had they made it to prod. As far as I can tell these have not been entirely addressed, although recent bug reports suggest that they might be getting closer.

      I want to love it, and I don't take open source projects like this for granted. But during my last production upgrade I chose to decommission Litestream in favor of a dumber, less granular solution using sqlite3_rsync and nightly backups because there is no point in using a backup system that is not rock solid.

    • 0cf8612b2e1e2 hours ago
      Postgres also does not synchronously replicate for free. You can setup both to get a confirmation write if you require that durability.
      • orf2 hours ago
        > postgresql also does not synchronously replicate

        By default. Generally your primary database is in a completely different failure category than a kubernetes node running an ephemeral workflow pod.

        • 0cf8612b2e1ean hour ago
          Either you have durable storage or you do not. SQLite and Postgres can both ensure local durability of commits. If you want distributed durability, you need to ship that data elsewhere. That is another Postgres node, object store, whatever that’s still an external dependency.
      • paulddraperan hour ago
        Not for free, but without the needing additional software.

          synchronous_commit = on
        • 0cf8612b2e1ean hour ago
          That’s about the local transaction, not replication. SQLite WAL also gives you strict durability.

            PRAGMA synchronous = full
    • bootsmann2 hours ago
      S3 is strongly consistent, if you need it anyways you can just use s3 keys to deconflict and store the workflow state.
      • orf2 hours ago
        Yes, but directly using s3 as a key-value database is completely different from using SQLite + litestream.
    • paulddraperan hour ago
      "Durable workflows without the durability"

      That's distributed workflows :)

    • dilyevskyan hour ago
      i mean it's durable as long as nothing crashes or litestream has a data corruption bug which only happens every other release...
  • CoderAshton30 minutes ago
    [dead]
  • steveharing1an hour ago
    [dead]