Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
An Introduction to LiteStack for Ruby on Rails (appsignal.com)
91 points by unripe_syntax on Sept 27, 2023 | hide | past | favorite | 37 comments


Very compelling architecture for projects that don't require massive horizontal scaling. Those looking for replicas/backups can add Litestream https://litestream.io


The article is actually a great introduction to interfacing a Rails app to Replicate AI!


I agree. I didn't learn anything about using LiteStack in a Rails App, but I did enjoy the article and learned of a few new gems and services. The article is the first part of a series and so hopefully in the next part they get into the integration of LiteStack with the app.


They will


Oh dang I love this.

I also wish someone would take something like this and go full Phoenix with it.


Phoenix already doesn't need Redis for asynchronous jobs and caching. I'm using Phoenix on SQLite on a project right now, and it's been working pretty flawlessly. It's as easy as `mix phx.new MyProject --database sqlite3`.


Phoenix?


Ruby off Rails inspired framework for Elixir.


Something feels wrong to use Current.account in models.


I see conventions like that as an acknowledgement that Rails often gives up purity in favour of simplicity. It makes this decision quite often, primarily because it works for Basecamp, but also it keeps the mental model simple, especially for juniors learning the ropes.

I've not seen many places that actually use it. Instead there are several other layers of patterns that try to keep things decoupled but introduce a different kind of complexity. And the implementation is different every time (Ruby devs love their custom service/command DSLs).


It is in fact how it was designed to be used, you can read the reasoning here: https://dev.37signals.com/globals-callbacks-and-other-sacril...


The reasoning being basically "fuck Ruby and consistent OOP practices, this is how we roll". I used to be fine with this, but the more I work with Rails, the more I feel like it's trying to make me a worse programmer. Business logic in controllers, service "objects" (not actually objects at all), the OOP abomination that are models with dozens of different behaviors and agendas inherited via concerns. In Rails you can always pick your poison, but you don't seem to be allowed not to be poisoned.


> Maximalist positions are a thing in our industry. Take a technique, outline its drawbacks, extrapolate you can’t use it under any circumstance, and ban it forever. We are lucky that Rails embraces exactly the opposite mindset as one of its pillars.


You may want look into dry-transaction and railway oriented programming.


Or you could give it up and move to Phoenix; I've never looked back.


Link?



Yeah I think it's one of those features that people generally steer away from. Ironically, if you stick to the "Rails way" of doing things I don't think you would ever encounter it.


Agree, models just data layer, not a place for business logic IMO


VM with 1GB ram and some swap file can easily run rail app, Postgres and redis. With that you don’t have to limit yourself to not able to scale later. I never used sqlite, can it be used by multiple process simultaneously? Eg rails server and rails console


When you open your database connection in WAL journal mode, you can have multiple concurrent readers. This is the new default for all Rails applications. WAL mode doesn’t allow concurrent writers, but you are often talking about milliseconds to wait for the busy connection to resolve, and SQLite retries for you invisibly.


Is there any restriction on how many rails apps can be run on a 5$ digital ocean droplet?


Yes, memory. 4$ droplets have only 512mb. that's barely enough to run bundle install for one application.

6$ droplets give you 1GB and that's plenty for one app,


You might have some success if you run the build before deploying it (provided you use the same arch as the droplet). It's not going to give you a lot to work with and Puma's default config will take up most of it.

A 1/2GB box could run the bare minimum if you host the database on it as well. For a small scale app or a hobby/toy project that's going to do just fine.


You can run any number of them if you turn swap on. It will just be very slow.



What would be the deployment strategy here?

Would it have to be manual deployments? Since the infrastructure for other approaches usually assumes that there isn’t any critical data on a single instance.

The .sqlite file would have to be persisted somehow?


Yes, the .sqlite file needs to be persisted across deployments. It is fairly common for the /storage directory to be persisted across deployments. The Kamal deployment tool will use this directory. The Hatchbox.io service likewise uses a persisted /storage directory.

This doesn’t mean that you have to have manual deployments tho. You simply need a file system and some persisted storage, which you should already have as most deployment setups don’t want to nuke and pave every static asset on every deployment.


It says people are using sqlite for production. How big can you grow your database before it becomes a problem ?



The limiting factor isn't the size of the dataset, but the rate of writes.


thats interesting I thought it would be faster than your avg database. I'll have to dig into it.


Something else will be a problem...before size of sqlite is a problem.


thanks, yeah I haven't dug deep enought to understand what those would be yet.


With binary search and indexes, why should size be a problem?


As big as your disk/SSD.


This is neat! I like.

It reminds me somewhat of Turso.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: