Estamos usando faunadb combinado con trabajadores de cloudflare pero lamentablemente lo encontramos bastante lento.
Estamos usando la opción clásica de base de datos y tenemos el cliente configurado así:
const faunaClient = new faunadb.Client({ domain: 'db.fauna.com', secret: FAUNA_SECRET_KEY });Una consulta de ejemplo que obtiene registros de una colección:
return faunaClient.query( Map( Paginate( Documents(Collection(collection)), paginateOptions ), Lambda(x => Get(x)) ) );Esta colección tiene alrededor de 20 registros y estos son los tiempos para obtener dicha colección:
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)¿Estoy haciendo algo mal o estos tiempos son los esperados?
Un ejemplo para simplemente recuperar un registro:
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)Y finalmente si creo un registro:
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)En este momento estoy usando el plan gratuito, pero planeo actualizarme al plan pago. Entiendo que las consultas deberían ser más lentas debido a la fuerte consistencia, pero parece que no puedo coincidir con los tiempos esperados en el sitio web de faunas:
Latencia si no hago ninguna consulta:
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)¿Alguna idea de lo que puedo estar haciendo mal?