We are using faunadb combined with cloudflare workers but unfortunately find it pretty slow.
We are using the classic option for database and have the client configured like so:
const faunaClient = new faunadb.Client({
domain: 'db.fauna.com',
secret: FAUNA_SECRET_KEY
});
An example query which gets records from a collection:
return faunaClient.query(
Map(
Paginate(
Documents(Collection(collection)),
paginateOptions
),
Lambda(x => Get(x))
)
);
This collection has around 20 records in and these are the times for getting said collection:
GET /v1/users?limit=2 200 OK (974.23ms)
GET /v1/users?limit=2 200 OK (903.74ms)
GET /v1/users?limit=2 200 OK (1451.97ms)
GET /v1/users?limit=2 200 OK (1228.47ms)
GET /v1/users?limit=2 200 OK (236.18ms)
GET /v1/users?limit=2 200 OK (102.01ms)
GET /v1/users?limit=2 200 OK (567.96ms)
GET /v1/users?limit=2 200 OK (490.67ms)
GET /v1/users?limit=2 200 OK (302.76ms)
Am I doing something wrong or are these times expected?
An example for just retrieving one record:
const user = await faunaClient.query(
Get(
Match(Index('users_search_by_email'), email)
)
)
GET /v1/users/331905953155777099 200 OK (386.23ms)
GET /v1/users/331905953155777099 200 OK (368.34ms)
GET /v1/users/331905953155777099 200 OK (298.62ms)
GET /v1/users/331905953155777099 200 OK (96.77ms)
GET /v1/users/331905953155777099 200 OK (396.50ms)
GET /v1/users/331905953155777099 200 OK (247.14ms)
GET /v1/users/331905953155777099 200 OK (175.26ms)
GET /v1/users/331905953155777099 200 OK (146.29ms)
GET /v1/users/331905953155777099 200 OK (313.30ms)
And finally if I create a record:
return faunaClient.query(
Create(
Collection(collection),
{
data: userBody
}
)
);
POST /v1/users 201 Created (615.84ms)
POST /v1/users 201 Created (419.30ms)
POST /v1/users 201 Created (407.91ms)
POST /v1/users 201 Created (144.86ms)
POST /v1/users 201 Created (836.91ms)
POST /v1/users 201 Created (465.37ms)
Right now I am using the free plan but plan to upgrade to the paid plan. I understand that the queries should be slower due to the strong consistency but I can’t seem to match the expected times on faunas website:
Latency if I don’t make any queries:
GET /v1/users?limit=2 200 OK (7.54ms)
GET /v1/users?limit=2 200 OK (1.61ms)
GET /v1/users?limit=2 200 OK (1.62ms)
GET /v1/users?limit=2 200 OK (1.42ms)
GET /v1/users?limit=2 200 OK (2.37ms)
GET /v1/users?limit=2 200 OK (2.02ms)
GET /v1/users?limit=2 200 OK (2.16ms)
Any ideas what I may be doing wrong?