mastodon.uno è uno dei tanti server Mastodon indipendenti che puoi usare per partecipare al fediverso.
Mastodon.Uno è la principale comunità mastodon italiana. Con 77.000 iscritti è il più grande nodo Mastodon italiano: anima ambientalista a supporto della privacy e del mondo Open Source.

Statistiche del server:

6,2K
utenti attivi

#rails

28 post23 partecipanti0 post oggi
Julik Tarkhanov · A Can of Shardines: SQLite Multitenancy With RailsThere is a pattern I am very fond of - “one database per tenant” in web applications with multiple, isolated users. Recently, I needed to fix an application I had for a long time where this database-per-tenant multitenancy utterly broke down, because I was doing connection management wrong. Which begat the question: how do you even approach doing it right? And it turns out I was not alone in this. The most popular gem for multitenancy - Apartment - which I have even used in my failed startup back in the day - has the issue too. The culprit of does not handle multithreading very well is actually deeper. Way deeper. Doing runtime-defined multiple databases with Rails has only recently become less haphazard, and there are no tools either via gems or built-in that facilitate these flows. It has also accrued a ton of complexity, and also changes with every major Rails revision. TL;DR If you need to do database-per-tenant multitenancy with Rails or ActiveRecord right now - grab the middleware from this gist and move on. If you are curious about the genesis of this solution, strap in - we are going on a tour of a sizeable problem, and of an API of stature - the ActiveRecord connection management. Read on and join me on the ride! Many thanks to Kir Shatrov and Stephen Margheim for their help in this.

🌘 沙丁魚罐頭:使用 Rails 實現 SQLite 多租戶架構
➤ 克服 ActiveRecord 的限制,實現高效能多租戶架構
blog.julik.nl/2025/04/a-can-of
本文探討了在 Rails 應用程式中實作「每個租戶一個資料庫」架構的挑戰。作者分享了過去在維護一個使用此架構的應用程式時遇到的問題,並指出現有的多租戶 gem (如 Apartment) 也存在類似的線程安全問題。文章深入探討了 ActiveRecord 連線管理機制,以及 Rails 如何使看似簡單的任務變得複雜,並提供了一個可行的解決方案:一個中間件,能有效處理多租戶環境下的資料庫連線。作者強調了使用 SQLite 作為小型專案的優勢,例如易於配置、備份及除錯,並指出此架構能有效限制資料庫規模,降低複雜性。
+ 這篇文章深入淺出地分析了 Rails 多租戶架構的難點,對於正在考慮類似方案的開發者來說,非常有參考價值。
+ 作者的經驗分享很實用,提供的中間件解決方案讓我看到了希望,可以嘗試應用在我
#Rails #SQLite #多租戶 #資料庫架構

Julik Tarkhanov · A Can of Shardines: SQLite Multitenancy With RailsThere is a pattern I am very fond of - “one database per tenant” in web applications with multiple, isolated users. Recently, I needed to fix an application I had for a long time where this database-per-tenant multitenancy utterly broke down, because I was doing connection management wrong. Which begat the question: how do you even approach doing it right? And it turns out I was not alone in this. The most popular gem for multitenancy - Apartment - which I have even used in my failed startup back in the day - has the issue too. The culprit of does not handle multithreading very well is actually deeper. Way deeper. Doing runtime-defined multiple databases with Rails has only recently become less haphazard, and there are no tools either via gems or built-in that facilitate these flows. It has also accrued a ton of complexity, and also changes with every major Rails revision. TL;DR If you need to do database-per-tenant multitenancy with Rails or ActiveRecord right now - grab the middleware from this gist and move on. If you are curious about the genesis of this solution, strap in - we are going on a tour of a sizeable problem, and of an API of stature - the ActiveRecord connection management. Read on and join me on the ride! Many thanks to Kir Shatrov and Stephen Margheim for their help in this.