-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement wasm-rdbms interface for standardized database access #1016
Comments
/bounty $5000 |
💎 $5,000 bounty • Golem CloudSteps to solve:
Thank you for contributing to golemcloud/golem! Add a bounty • Share on socials
|
/attempt #1016 Options |
I am assuming you mean and will the |
@palash25 Please don't work on this one, it's already taken. I will have new bounties up soon. |
hey @justcoon are you working on it ? |
hi @debaa98 , yes I am working on it |
only one person can attempt it at the same time? |
@volfcan Yes, please! But be on the look out for many more bounties in the next 2 months. |
hey @justcoon it seems quite inactive so will i take the issue ? |
Hi, @debaa98 , I am working on this issue |
WASM RDBMS
WASM components do not have access to databases natively. Rather, they must obtain all functionality from their host, through the component model types.
Although there exists a
wasi-sql
project, which intends to provide a WASI standard for database access, it is still in its infancy and shows no signs of active development.Rather than await the completion of
wasi-sql
, WASM startup Fermyon introduced a series of WIT interfacespostgres
,sqlite
, andmysql
in their WASM-native framework Spin, which use a related series of database types. These interfaces are supported by the Spin host environment.It is not clear if Fermyon’s interfaces will become standard or not, or if work will be resumed on the earlier (but far less complete)
wasi-sql
. Rather than wait for the lengthy process of standardization to produce something useful, Golem needs to support some level of database access now, so that developers using databases have options.This specification calls for the development of a new
💡wasm-rdbms
interface, which is designed to support features common to mainstream databases, as well as a corresponding set of implementations in Golem, powered by a low-level Rust library.Currently, this design only facilitates connection with existing databases, rather than supporting the newer paradigm of provisioning databases based on their demonstrated usage inside the code. However, as connecting to existing databases is something that needs to be supported regardless, it makes sense to first start with this feature.
Overview
The basic approach of this language-agnostic interface to databases is to have a generalized core upon which all specific database interfaces can depend.
This allows new databases to be introduced cheaply, while still respecting the fact that developers must necessarily program against specific databases, due to differences in column types, SQL syntax, and other features.
Common Elements
Common elements belong to the same generic package and have generic interface names.
They include the following, as well as related supporting types:
Unique Elements
Unique elements belong to database-specific packages, with database-specific interface names. They represent aspects of a database interface that benefit from tying to one specific database.
WIT Sketch
Common Elements
Something like the following should work for most databases (other than SQLite):
Unique Elements
Something like the following should work for databases that are not SQLite:
SQLite will require its own interface, perhaps inspired by the one in Spin.
Host Implementation
The host implementation will live in the worker-executor service and will use best-in-class async Rust libraries to provide implementations of the specified interfaces.
One slight complication is that a
connection
in the guest must not map to aconnection
in the host. The reason for this is that on a single worker-executor node, there may exist thousands of workers, and these workers should not maintain their own independent connections to the database.Therefore, in order to improve performance, it is necessary to perform connection pooling in the host, so that if only 20 concurrent connections are needed across all workers, then only 20 concurrent connections are created and maintained.
Note that if the
wasm-rdbms
interface improves in power to allow interleaving database updates with side-effects as part of a single database transaction, then pooling becomes much more difficult. However, with the current interface, the only two things a worker can do with a connection arequery
andexecute
, which atomically return results; and if those results are small enough to fit in memory, then there is no need to keep an underlying connection dedicated to the worker (instead, it can be reused for another worker).The text was updated successfully, but these errors were encountered: