├── .gitignore ├── README.md ├── initnewsdb ├── .gitignore ├── fauna.txt ├── initCassandra.js ├── initDynamo.js ├── initFauna.js ├── initFirestore.js ├── initMongo.js ├── initRedis.js ├── initRedisMultizone.js ├── initRedisRest.js ├── news.json ├── package-lock.json ├── package.json ├── query.gql └── reset.gql ├── news-app ├── .gitignore ├── README.md ├── package-lock.json ├── package.json ├── public │ ├── cover-serverless-battleground.jpg │ ├── favicon.ico │ ├── index.html │ ├── logo192.png │ ├── logo512.png │ ├── manifest.json │ └── robots.txt └── src │ ├── App.css │ ├── App.js │ ├── App.test.js │ ├── index.css │ ├── index.js │ ├── logo.svg │ ├── old.css │ ├── reportWebVitals.js │ └── setupTests.js ├── newsapis ├── .gitignore ├── cassandraHandler.js ├── dynamoHandler.js ├── faunaHandler.js ├── faunaUsHandler.js ├── gcp │ ├── index.js │ └── package.json ├── histogramHandler.js ├── mongoHandler.js ├── package-lock.json ├── package.json ├── redisHandler.js ├── redisMultizoneHandler.js └── redisRestHandler.js └── readme.md /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | 3 | .idea 4 | *iml 5 | 6 | node_modules 7 | 8 | lib/core/metadata.js 9 | lib/core/MetadataBlog.js 10 | 11 | website/translated_docs 12 | website/build/ 13 | website/yarn.lock 14 | website/node_modules 15 | website/i18n/* 16 | website/package-lock.json 17 | .vercel -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # latency-comparison 2 | Latency Comparison among Serverless Databases: DynamoDB, FaunaDB, MongoDB, Cassandra, Firestore and Upstash 3 | 4 | 5 | Check [the live application](https://serverless-battleground.vercel.app/) and [the blogpost](https://blog.upstash.com/serverless-database-benchmark). 6 | 7 | -------------------------------------------------------------------------------- /initnewsdb/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | functions-* 5 | 6 | serverless.yml 7 | # Serverless directories 8 | .serverless 9 | .env -------------------------------------------------------------------------------- /initnewsdb/fauna.txt: -------------------------------------------------------------------------------- 1 | CreateIndex({ 2 | name: "section_by_view_count", 3 | unique: false, 4 | serialized: false, 5 | source: Collection("news"), 6 | terms: [ 7 | { 8 | field: ["data", "section"] 9 | } 10 | ], 11 | values: [ 12 | { 13 | field: ["data", "view_count"], reverse: true 14 | }, 15 | { 16 | field: ["ref"] 17 | } 18 | ] 19 | }) 20 | 21 | 22 | Map( 23 | Paginate( 24 | Documents(Collection('news')), 25 | { size: 9999 } 26 | ), 27 | Lambda( 28 | ['ref'], 29 | Delete(Var('ref')) 30 | ) 31 | ) -------------------------------------------------------------------------------- /initnewsdb/initCassandra.js: -------------------------------------------------------------------------------- 1 | const fetch = require("node-fetch"); 2 | const fs = require("fs"); 3 | 4 | 5 | const ASTRA_DB_ID = '5864e932-14a7-4335-8d84-16f40e451b5b' 6 | const ASTRA_DB_REGION = 'us-east-1' 7 | const ASTRA_DB_KEYSPACE = 'news' 8 | const ASTRA_DB_APPLICATION_TOKEN = '' 9 | 10 | /* 11 | 12 | curl --request POST \ 13 | --url https://${ASTRA_DB_ID}-${ASTRA_DB_REGION}.apps.astra.datastax.com/api/rest/v1/keyspaces/${ASTRA_DB_KEYSPACE}/tables/rest_example_products/rows \ 14 | --header 'content-type: application/json' \ 15 | --header "x-cassandra-token: ${ASTRA_DB_APPLICATION_TOKEN}" \ 16 | --data '{"columns":[{"name":"id","value":"e9b6c02d-0604-4bab-a3ea-6a7984654631"},{"name":"productname","value":"Heavy Lift Arms"},{"name":"description","value":"Heavy lift arms capable of lifting 1,250 lbs of weight per arm. Sold as a set."},{"name":"price","value":"4199.99"},{"name":"created","value":"2019-01-10T09:48:31.020Z"}]}' 17 | 18 | INSERT INTO news.temp (id, section, headline, 19 | abstract, 20 | url, 21 | image, 22 | view_count) 23 | VALUES (2, 'world','h1', 'abs', 'url', 'img', 100); 24 | 25 | 26 | */ 27 | 28 | const url = "https://5864e932-14a7-4335-8d84-16f40e451b5b-us-east-1.apps.astra.datastax.com/api/rest/v1/keyspaces/news/tables/items/rows" 29 | 30 | 31 | async function insert(id, section, headline, abstract, newsurl, image, view_count) { 32 | 33 | let data = `{"columns":[ {"name":"id","value":${id}},` 34 | + `{"name":"section","value":"${section}"},` 35 | + `{"name":"headline","value":"${headline}"},` 36 | + `{"name":"abstract","value":"${abstract}"},` 37 | + `{"name":"url","value":"${newsurl}"},` 38 | + `{"name":"image","value":"${image}"},` 39 | + `{"name":"view_count","value":${view_count}}]}`; 40 | const response = await fetch(url, { 41 | method: 'POST', // *GET, POST, PUT, DELETE, etc. 42 | mode: 'cors', // no-cors, *cors, same-origin 43 | cache: 'no-cache', // *default, no-cache, reload, force-cache, only-if-cached 44 | credentials: 'same-origin', // include, *same-origin, omit 45 | headers: { 46 | 'Content-Type': 'application/json', 47 | 'x-cassandra-token': process.env.CASSANDRA_TOKEN 48 | }, 49 | redirect: 'follow', // manual, *follow, error 50 | referrerPolicy: 'no-referrer', // no-referrer, *no-referrer-when-downgrade, origin, origin-when-cross-origin, same-origin, strict-origin, strict-origin-when-cross-origin, unsafe-url 51 | body: data // body data type must match "Content-Type" header 52 | }); 53 | return id 54 | } 55 | 56 | 57 | async function main() { 58 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 59 | const len = news.length; 60 | // insert(67, "world", "Heavy Lift Arms", "Heavy Lift Arms abs", "htps://dddd", "image", 178 ); 61 | for (i = 0; i < len; i++) { 62 | let headline = news[i].headline.main; 63 | let abstract = news[i].abstract; 64 | let newsurl = news[i].web_url; 65 | let section = news[i].section_name; 66 | let image 67 | if (news[i].multimedia && news[i].multimedia.length > 0) { 68 | image = "https://www.nytimes.com/" + news[i].multimedia[0].url 69 | } else { 70 | image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 71 | } 72 | let id = i + 1; 73 | let view_count = Math.floor(Math.random() * 1000); 74 | // setTimeout(function(){ insert(id, section, headline, abstract, newsurl, image, view_count ); }, 1100 * i ); 75 | console.log(await (insert(id, section, headline, abstract, newsurl, image, view_count))) 76 | } 77 | } 78 | 79 | main(); -------------------------------------------------------------------------------- /initnewsdb/initDynamo.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | 3 | const AWS = require("aws-sdk"); 4 | 5 | AWS.config.update({ 6 | region: "us-west-1" 7 | }); 8 | 9 | const docClient = new AWS.DynamoDB.DocumentClient(); 10 | 11 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 12 | const len = news.length; 13 | 14 | 15 | 16 | for(i = 0; i < len; i++) { 17 | let headline = news[i].headline.main; 18 | let abstract = news[i].abstract; 19 | let url = news[i].web_url; 20 | let section = news[i].section_name; 21 | let image 22 | if(news[i].multimedia && news[i].multimedia.length > 0) { 23 | image = "https://www.nytimes.com/" + news[i].multimedia[0].url 24 | } 25 | else { 26 | image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 27 | } 28 | let id = i+1; 29 | let view_count = Math.floor(Math.random() * 1000); 30 | 31 | var params = { 32 | TableName: "news", 33 | Item: { 34 | id: id, 35 | url: url, 36 | headline: headline, 37 | abstract: abstract, 38 | image: image, 39 | section: section, 40 | view_count: view_count 41 | } 42 | }; 43 | 44 | docClient.put(params, function(err, data) { 45 | if (err) { 46 | console.error("Unable to add news", url, ". Error JSON:", JSON.stringify(err, null, 2)); 47 | } else { 48 | console.log("PutItem succeeded:", url, id); 49 | } 50 | }); 51 | 52 | } 53 | console.log(len) 54 | 55 | -------------------------------------------------------------------------------- /initnewsdb/initFauna.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const faunadb = require("faunadb"); 3 | 4 | require('dotenv').config() 5 | /* configure faunaDB Client with our secret */ 6 | const client = new faunadb.Client({ 7 | secret: process.env.FAUNA_US_SECRET, 8 | domain: 'db.us.fauna.com' 9 | }) 10 | const q = faunadb.query 11 | 12 | 13 | async function main() { 14 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 15 | const len = news.length; 16 | 17 | console.log(len) 18 | let count = 0; 19 | for (i = 0; i < len; i++) { 20 | let item = {} 21 | let view_count = Math.floor(Math.random() * 1000); 22 | let section = news[i].section_name; 23 | item.id = i + 1; 24 | item.section = section; 25 | item.headline = news[i].headline.main; 26 | item.abstract = news[i].abstract; 27 | item.view_count = view_count; 28 | item.url = news[i].web_url; 29 | if (news[i].multimedia && news[i].multimedia.length > 0) { 30 | item.image = "https://www.nytimes.com/" + news[i].multimedia[0].url 31 | } else { 32 | item.image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 33 | } 34 | 35 | await client.query(q.Create(q.Collection("news2"), {data: item})) 36 | .then((response) => { 37 | console.log("success", response) 38 | count++; 39 | console.log(len); 40 | }).catch((error) => { 41 | console.log("error", error) 42 | }) 43 | } 44 | } 45 | 46 | main(); 47 | 48 | 49 | -------------------------------------------------------------------------------- /initnewsdb/initFirestore.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const admin = require('firebase-admin'); 3 | 4 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 5 | const len = news.length; 6 | 7 | const collectionName = "news" 8 | 9 | async function main() { 10 | 11 | const serviceAccount = require('./functions-317005-firebase-adminsdk-coziy-8514812b2d.json'); 12 | 13 | admin.initializeApp({ 14 | credential: admin.credential.cert(serviceAccount) 15 | }); 16 | 17 | const db = admin.firestore(); 18 | 19 | const snapshot = await db.collection(collectionName).where('section', '==', 'World') 20 | .orderBy('view_count', 'desc').limit(10).get(); 21 | if (snapshot.empty) { 22 | console.log('No matching documents.'); 23 | return; 24 | } else { 25 | var docs = snapshot.docs.map(doc => doc.data()); 26 | console.log('Document data:', docs); 27 | let x= JSON.stringify(docs); 28 | // console.log("jjj" + x); 29 | } 30 | 31 | snapshot.forEach(doc => { 32 | // console.log(doc.id, '=>', doc.data()); 33 | }); 34 | 35 | for (i = 0; i < 0; i++) { 36 | let headline = news[i].headline.main; 37 | let abstract = news[i].abstract; 38 | let url = news[i].web_url; 39 | let section = news[i].section_name; 40 | let image 41 | if (news[i].multimedia && news[i].multimedia.length > 0) { 42 | image = "https://www.nytimes.com/" + news[i].multimedia[0].url 43 | } else { 44 | image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 45 | } 46 | 47 | if (section !== "WorldXXX") { 48 | let id = i + 1; 49 | let view_count = Math.floor(Math.random() * 1000); 50 | 51 | var obj = { 52 | url: url, 53 | headline: headline, 54 | abstract: abstract, 55 | image: image, 56 | section: section, 57 | view_count: view_count 58 | }; 59 | const res = await db.collection(collectionName).doc(id + "").set(obj); 60 | 61 | console.log(id) 62 | console.log(res) 63 | } 64 | } 65 | } 66 | 67 | main(); 68 | -------------------------------------------------------------------------------- /initnewsdb/initMongo.js: -------------------------------------------------------------------------------- 1 | const {MongoClient} = require('mongodb'); 2 | const fs = require("fs"); 3 | 4 | const uri = process.env.MONGO_URL; 5 | 6 | const client = new MongoClient(uri, {useNewUrlParser: true, useUnifiedTopology: true}); 7 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 8 | const len = news.length; 9 | 10 | client.connect(err => { 11 | if (err) { 12 | console.log(err) 13 | return 14 | } 15 | const collection = client.db("news").collection("news"); 16 | 17 | for (i = 0; i < len; i++) { 18 | let headline = news[i].headline.main; 19 | let abstract = news[i].abstract; 20 | let url = news[i].web_url; 21 | let section = news[i].section_name; 22 | let image 23 | if (news[i].multimedia && news[i].multimedia.length > 0) { 24 | image = "https://www.nytimes.com/" + news[i].multimedia[0].url 25 | } else { 26 | image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 27 | } 28 | let id = i + 1; 29 | let view_count = Math.floor(Math.random() * 1000); 30 | 31 | var obj = { 32 | id: id, 33 | url: url, 34 | headline: headline, 35 | abstract: abstract, 36 | image: image, 37 | section: section, 38 | view_count: view_count 39 | }; 40 | collection.insertOne(obj, function(err, res) { 41 | if (err) throw err; 42 | console.log("1 document inserted:" + id); 43 | }) 44 | } 45 | }); 46 | 47 | console.log(len) 48 | -------------------------------------------------------------------------------- /initnewsdb/initRedis.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const Redis = require("ioredis"); 3 | 4 | const client = new Redis(process.env.REDIS_URL); 5 | 6 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 7 | const len = news.length; 8 | 9 | client.flushdb().then(() => { 10 | for (i = 0; i < len; i++) { 11 | let item = {} 12 | let view_count = Math.floor(Math.random() * 1000); 13 | let section = news[i].section_name; 14 | item.id = i + 1; 15 | item.section = section; 16 | item.headline = news[i].headline.main; 17 | item.abstract = news[i].abstract; 18 | item.view_count = view_count; 19 | item.url = news[i].web_url; 20 | if (news[i].multimedia && news[i].multimedia.length > 0) { 21 | item.image = "https://www.nytimes.com/" + news[i].multimedia[0].url 22 | } else { 23 | item.image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 24 | } 25 | client.zadd(section, view_count, JSON.stringify(item)).then( 26 | (res) => console.log(res + ": inserted:" + item.url) 27 | ); 28 | } 29 | console.log(len) 30 | } 31 | ) 32 | 33 | 34 | -------------------------------------------------------------------------------- /initnewsdb/initRedisMultizone.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const Redis = require("ioredis"); 3 | require('dotenv').config(); 4 | 5 | 6 | const client = new Redis(process.env.REDIS_MZ_URL); 7 | 8 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 9 | const len = news.length; 10 | 11 | client.flushdb().then(() => { 12 | for (i = 0; i < len; i++) { 13 | let item = {} 14 | let view_count = Math.floor(Math.random() * 1000); 15 | let section = news[i].section_name; 16 | item.id = i + 1; 17 | item.section = section; 18 | item.headline = news[i].headline.main; 19 | item.abstract = news[i].abstract; 20 | item.view_count = view_count; 21 | item.url = news[i].web_url; 22 | if (news[i].multimedia && news[i].multimedia.length > 0) { 23 | item.image = "https://www.nytimes.com/" + news[i].multimedia[0].url 24 | } else { 25 | item.image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 26 | } 27 | client.zadd(section, view_count, JSON.stringify(item)).then( 28 | (res) => console.log(res + ": inserted:" + item.url) 29 | ); 30 | } 31 | console.log(len) 32 | } 33 | ) 34 | 35 | 36 | -------------------------------------------------------------------------------- /initnewsdb/initRedisRest.js: -------------------------------------------------------------------------------- 1 | const fs = require("fs"); 2 | const Redis = require("ioredis"); 3 | require('dotenv').config(); 4 | 5 | 6 | const client = new Redis(process.env.REDIS_REST_URL); 7 | 8 | const news = JSON.parse(fs.readFileSync('news.json', 'utf8')).response.docs; 9 | const len = news.length; 10 | 11 | client.flushdb().then(() => { 12 | for (i = 0; i < len; i++) { 13 | let item = {} 14 | let view_count = Math.floor(Math.random() * 1000); 15 | let section = news[i].section_name; 16 | item.id = i + 1; 17 | item.section = section; 18 | item.headline = news[i].headline.main; 19 | item.abstract = news[i].abstract; 20 | item.view_count = view_count; 21 | item.url = news[i].web_url; 22 | if (news[i].multimedia && news[i].multimedia.length > 0) { 23 | item.image = "https://www.nytimes.com/" + news[i].multimedia[0].url 24 | } else { 25 | item.image = "https://www.nytimes.com/vi-assets/static-assets/ios-ipad-144x144-28865b72953380a40aa43318108876cb.png"; 26 | } 27 | client.zadd(section, view_count, JSON.stringify(item)).then( 28 | (res) => console.log(res + ": inserted:" + item.url) 29 | ); 30 | } 31 | console.log(len) 32 | } 33 | ) 34 | 35 | 36 | -------------------------------------------------------------------------------- /initnewsdb/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "initmoviesdb", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "name": "initmoviesdb", 9 | "version": "1.0.0", 10 | "license": "ISC", 11 | "dependencies": { 12 | "aws-sdk": "^2.864.0", 13 | "faunadb": "^4.1.1", 14 | "ioredis": "^4.24.2", 15 | "node-fetch": "^2.6.1" 16 | } 17 | }, 18 | "node_modules/abort-controller": { 19 | "version": "3.0.0", 20 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", 21 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", 22 | "dependencies": { 23 | "event-target-shim": "^5.0.0" 24 | }, 25 | "engines": { 26 | "node": ">=6.5" 27 | } 28 | }, 29 | "node_modules/aws-sdk": { 30 | "version": "2.864.0", 31 | "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.864.0.tgz", 32 | "integrity": "sha512-QbxIFgJLHP/v2snYC0udrQHQcRRPZjALv2pTvdVP78BBmM4YGuuI3U6YRMfHb/a41m2JDriXaqUA5+HSYmCm3w==", 33 | "dependencies": { 34 | "buffer": "4.9.2", 35 | "events": "1.1.1", 36 | "ieee754": "1.1.13", 37 | "jmespath": "0.15.0", 38 | "querystring": "0.2.0", 39 | "sax": "1.2.1", 40 | "url": "0.10.3", 41 | "uuid": "3.3.2", 42 | "xml2js": "0.4.19" 43 | }, 44 | "engines": { 45 | "node": ">= 0.8.0" 46 | } 47 | }, 48 | "node_modules/base64-js": { 49 | "version": "1.5.1", 50 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 51 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" 52 | }, 53 | "node_modules/browser-detect": { 54 | "version": "0.2.28", 55 | "resolved": "https://registry.npmjs.org/browser-detect/-/browser-detect-0.2.28.tgz", 56 | "integrity": "sha512-KeWGHqYQmHDkCFG2dIiX/2wFUgqevbw/rd6wNi9N6rZbaSJFtG5kel0HtprRwCGp8sqpQP79LzDJXf/WCx4WAw==", 57 | "dependencies": { 58 | "core-js": "^2.5.7" 59 | } 60 | }, 61 | "node_modules/btoa-lite": { 62 | "version": "1.0.0", 63 | "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", 64 | "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" 65 | }, 66 | "node_modules/buffer": { 67 | "version": "4.9.2", 68 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", 69 | "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", 70 | "dependencies": { 71 | "base64-js": "^1.0.2", 72 | "ieee754": "^1.1.4", 73 | "isarray": "^1.0.0" 74 | } 75 | }, 76 | "node_modules/cluster-key-slot": { 77 | "version": "1.1.0", 78 | "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", 79 | "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==", 80 | "engines": { 81 | "node": ">=0.10.0" 82 | } 83 | }, 84 | "node_modules/core-js": { 85 | "version": "2.6.12", 86 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", 87 | "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==", 88 | "hasInstallScript": true 89 | }, 90 | "node_modules/cross-fetch": { 91 | "version": "3.1.1", 92 | "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.1.tgz", 93 | "integrity": "sha512-eIF+IHQpRzoGd/0zPrwQmHwDC90mdvjk+hcbYhKoaRrEk4GEIDqdjs/MljmdPPoHTQudbmWS+f0hZsEpFaEvWw==", 94 | "dependencies": { 95 | "node-fetch": "2.6.1" 96 | } 97 | }, 98 | "node_modules/debug": { 99 | "version": "4.3.1", 100 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", 101 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", 102 | "dependencies": { 103 | "ms": "2.1.2" 104 | }, 105 | "engines": { 106 | "node": ">=6.0" 107 | } 108 | }, 109 | "node_modules/denque": { 110 | "version": "1.5.0", 111 | "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", 112 | "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==", 113 | "engines": { 114 | "node": ">=0.10" 115 | } 116 | }, 117 | "node_modules/dotenv": { 118 | "version": "8.2.0", 119 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", 120 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", 121 | "engines": { 122 | "node": ">=8" 123 | } 124 | }, 125 | "node_modules/event-target-shim": { 126 | "version": "5.0.1", 127 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", 128 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", 129 | "engines": { 130 | "node": ">=6" 131 | } 132 | }, 133 | "node_modules/events": { 134 | "version": "1.1.1", 135 | "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", 136 | "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=", 137 | "engines": { 138 | "node": ">=0.4.x" 139 | } 140 | }, 141 | "node_modules/faunadb": { 142 | "version": "4.1.1", 143 | "resolved": "https://registry.npmjs.org/faunadb/-/faunadb-4.1.1.tgz", 144 | "integrity": "sha512-ekHtUgt+heYbaZXMWMB00Q7+DCiPKAubs2zbpNc4oMKamRxbL39MyzdNQNnCcSGOAJcLHPJbgOlDHK4y0Rkwrw==", 145 | "dependencies": { 146 | "abort-controller": "^3.0.0", 147 | "base64-js": "^1.2.0", 148 | "browser-detect": "^0.2.28", 149 | "btoa-lite": "^1.0.0", 150 | "cross-fetch": "^3.0.6", 151 | "dotenv": "^8.2.0", 152 | "fn-annotate": "^1.1.3", 153 | "object-assign": "^4.1.0", 154 | "util-deprecate": "^1.0.2" 155 | } 156 | }, 157 | "node_modules/fn-annotate": { 158 | "version": "1.2.0", 159 | "resolved": "https://registry.npmjs.org/fn-annotate/-/fn-annotate-1.2.0.tgz", 160 | "integrity": "sha1-KNoAARfephhC/mHzU/Qc9Mk6en4=", 161 | "engines": { 162 | "node": ">=0.10.0" 163 | } 164 | }, 165 | "node_modules/ieee754": { 166 | "version": "1.1.13", 167 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", 168 | "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" 169 | }, 170 | "node_modules/ioredis": { 171 | "version": "4.24.2", 172 | "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-4.24.2.tgz", 173 | "integrity": "sha512-SSuVXwoG747sZetxxs9gyAno5kfUfvo4s5mSZp4dh8vzuTnrtA5mTf2OjL6sPfIfNbVTROg2c+VbXceGlpucPQ==", 174 | "dependencies": { 175 | "cluster-key-slot": "^1.1.0", 176 | "debug": "^4.3.1", 177 | "denque": "^1.1.0", 178 | "lodash.defaults": "^4.2.0", 179 | "lodash.flatten": "^4.4.0", 180 | "p-map": "^2.1.0", 181 | "redis-commands": "1.7.0", 182 | "redis-errors": "^1.2.0", 183 | "redis-parser": "^3.0.0", 184 | "standard-as-callback": "^2.1.0" 185 | }, 186 | "engines": { 187 | "node": ">=6" 188 | } 189 | }, 190 | "node_modules/isarray": { 191 | "version": "1.0.0", 192 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 193 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 194 | }, 195 | "node_modules/jmespath": { 196 | "version": "0.15.0", 197 | "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", 198 | "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=", 199 | "engines": { 200 | "node": ">= 0.6.0" 201 | } 202 | }, 203 | "node_modules/lodash.defaults": { 204 | "version": "4.2.0", 205 | "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", 206 | "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" 207 | }, 208 | "node_modules/lodash.flatten": { 209 | "version": "4.4.0", 210 | "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", 211 | "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" 212 | }, 213 | "node_modules/ms": { 214 | "version": "2.1.2", 215 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 216 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 217 | }, 218 | "node_modules/node-fetch": { 219 | "version": "2.6.1", 220 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 221 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", 222 | "engines": { 223 | "node": "4.x || >=6.0.0" 224 | } 225 | }, 226 | "node_modules/object-assign": { 227 | "version": "4.1.1", 228 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 229 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", 230 | "engines": { 231 | "node": ">=0.10.0" 232 | } 233 | }, 234 | "node_modules/p-map": { 235 | "version": "2.1.0", 236 | "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", 237 | "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==", 238 | "engines": { 239 | "node": ">=6" 240 | } 241 | }, 242 | "node_modules/punycode": { 243 | "version": "1.3.2", 244 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", 245 | "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" 246 | }, 247 | "node_modules/querystring": { 248 | "version": "0.2.0", 249 | "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", 250 | "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", 251 | "engines": { 252 | "node": ">=0.4.x" 253 | } 254 | }, 255 | "node_modules/redis-commands": { 256 | "version": "1.7.0", 257 | "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", 258 | "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" 259 | }, 260 | "node_modules/redis-errors": { 261 | "version": "1.2.0", 262 | "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", 263 | "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=", 264 | "engines": { 265 | "node": ">=4" 266 | } 267 | }, 268 | "node_modules/redis-parser": { 269 | "version": "3.0.0", 270 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", 271 | "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", 272 | "dependencies": { 273 | "redis-errors": "^1.0.0" 274 | }, 275 | "engines": { 276 | "node": ">=4" 277 | } 278 | }, 279 | "node_modules/sax": { 280 | "version": "1.2.1", 281 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", 282 | "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" 283 | }, 284 | "node_modules/standard-as-callback": { 285 | "version": "2.1.0", 286 | "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", 287 | "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" 288 | }, 289 | "node_modules/url": { 290 | "version": "0.10.3", 291 | "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", 292 | "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", 293 | "dependencies": { 294 | "punycode": "1.3.2", 295 | "querystring": "0.2.0" 296 | } 297 | }, 298 | "node_modules/util-deprecate": { 299 | "version": "1.0.2", 300 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 301 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 302 | }, 303 | "node_modules/uuid": { 304 | "version": "3.3.2", 305 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", 306 | "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==", 307 | "bin": { 308 | "uuid": "bin/uuid" 309 | } 310 | }, 311 | "node_modules/xml2js": { 312 | "version": "0.4.19", 313 | "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", 314 | "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", 315 | "dependencies": { 316 | "sax": ">=0.6.0", 317 | "xmlbuilder": "~9.0.1" 318 | } 319 | }, 320 | "node_modules/xmlbuilder": { 321 | "version": "9.0.7", 322 | "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", 323 | "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=", 324 | "engines": { 325 | "node": ">=4.0" 326 | } 327 | } 328 | }, 329 | "dependencies": { 330 | "abort-controller": { 331 | "version": "3.0.0", 332 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", 333 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", 334 | "requires": { 335 | "event-target-shim": "^5.0.0" 336 | } 337 | }, 338 | "aws-sdk": { 339 | "version": "2.864.0", 340 | "resolved": "https://registry.npmjs.org/aws-sdk/-/aws-sdk-2.864.0.tgz", 341 | "integrity": "sha512-QbxIFgJLHP/v2snYC0udrQHQcRRPZjALv2pTvdVP78BBmM4YGuuI3U6YRMfHb/a41m2JDriXaqUA5+HSYmCm3w==", 342 | "requires": { 343 | "buffer": "4.9.2", 344 | "events": "1.1.1", 345 | "ieee754": "1.1.13", 346 | "jmespath": "0.15.0", 347 | "querystring": "0.2.0", 348 | "sax": "1.2.1", 349 | "url": "0.10.3", 350 | "uuid": "3.3.2", 351 | "xml2js": "0.4.19" 352 | } 353 | }, 354 | "base64-js": { 355 | "version": "1.5.1", 356 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 357 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" 358 | }, 359 | "browser-detect": { 360 | "version": "0.2.28", 361 | "resolved": "https://registry.npmjs.org/browser-detect/-/browser-detect-0.2.28.tgz", 362 | "integrity": "sha512-KeWGHqYQmHDkCFG2dIiX/2wFUgqevbw/rd6wNi9N6rZbaSJFtG5kel0HtprRwCGp8sqpQP79LzDJXf/WCx4WAw==", 363 | "requires": { 364 | "core-js": "^2.5.7" 365 | } 366 | }, 367 | "btoa-lite": { 368 | "version": "1.0.0", 369 | "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", 370 | "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" 371 | }, 372 | "buffer": { 373 | "version": "4.9.2", 374 | "resolved": "https://registry.npmjs.org/buffer/-/buffer-4.9.2.tgz", 375 | "integrity": "sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg==", 376 | "requires": { 377 | "base64-js": "^1.0.2", 378 | "ieee754": "^1.1.4", 379 | "isarray": "^1.0.0" 380 | } 381 | }, 382 | "cluster-key-slot": { 383 | "version": "1.1.0", 384 | "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", 385 | "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==" 386 | }, 387 | "core-js": { 388 | "version": "2.6.12", 389 | "resolved": "https://registry.npmjs.org/core-js/-/core-js-2.6.12.tgz", 390 | "integrity": "sha512-Kb2wC0fvsWfQrgk8HU5lW6U/Lcs8+9aaYcy4ZFc6DDlo4nZ7n70dEgE5rtR0oG6ufKDUnrwfWL1mXR5ljDatrQ==" 391 | }, 392 | "cross-fetch": { 393 | "version": "3.1.1", 394 | "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.1.tgz", 395 | "integrity": "sha512-eIF+IHQpRzoGd/0zPrwQmHwDC90mdvjk+hcbYhKoaRrEk4GEIDqdjs/MljmdPPoHTQudbmWS+f0hZsEpFaEvWw==", 396 | "requires": { 397 | "node-fetch": "2.6.1" 398 | } 399 | }, 400 | "debug": { 401 | "version": "4.3.1", 402 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", 403 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", 404 | "requires": { 405 | "ms": "2.1.2" 406 | } 407 | }, 408 | "denque": { 409 | "version": "1.5.0", 410 | "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", 411 | "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==" 412 | }, 413 | "dotenv": { 414 | "version": "8.2.0", 415 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", 416 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" 417 | }, 418 | "event-target-shim": { 419 | "version": "5.0.1", 420 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", 421 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" 422 | }, 423 | "events": { 424 | "version": "1.1.1", 425 | "resolved": "https://registry.npmjs.org/events/-/events-1.1.1.tgz", 426 | "integrity": "sha1-nr23Y1rQmccNzEwqH1AEKI6L2SQ=" 427 | }, 428 | "faunadb": { 429 | "version": "4.1.1", 430 | "resolved": "https://registry.npmjs.org/faunadb/-/faunadb-4.1.1.tgz", 431 | "integrity": "sha512-ekHtUgt+heYbaZXMWMB00Q7+DCiPKAubs2zbpNc4oMKamRxbL39MyzdNQNnCcSGOAJcLHPJbgOlDHK4y0Rkwrw==", 432 | "requires": { 433 | "abort-controller": "^3.0.0", 434 | "base64-js": "^1.2.0", 435 | "browser-detect": "^0.2.28", 436 | "btoa-lite": "^1.0.0", 437 | "cross-fetch": "^3.0.6", 438 | "dotenv": "^8.2.0", 439 | "fn-annotate": "^1.1.3", 440 | "object-assign": "^4.1.0", 441 | "util-deprecate": "^1.0.2" 442 | } 443 | }, 444 | "fn-annotate": { 445 | "version": "1.2.0", 446 | "resolved": "https://registry.npmjs.org/fn-annotate/-/fn-annotate-1.2.0.tgz", 447 | "integrity": "sha1-KNoAARfephhC/mHzU/Qc9Mk6en4=" 448 | }, 449 | "ieee754": { 450 | "version": "1.1.13", 451 | "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz", 452 | "integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg==" 453 | }, 454 | "ioredis": { 455 | "version": "4.24.2", 456 | "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-4.24.2.tgz", 457 | "integrity": "sha512-SSuVXwoG747sZetxxs9gyAno5kfUfvo4s5mSZp4dh8vzuTnrtA5mTf2OjL6sPfIfNbVTROg2c+VbXceGlpucPQ==", 458 | "requires": { 459 | "cluster-key-slot": "^1.1.0", 460 | "debug": "^4.3.1", 461 | "denque": "^1.1.0", 462 | "lodash.defaults": "^4.2.0", 463 | "lodash.flatten": "^4.4.0", 464 | "p-map": "^2.1.0", 465 | "redis-commands": "1.7.0", 466 | "redis-errors": "^1.2.0", 467 | "redis-parser": "^3.0.0", 468 | "standard-as-callback": "^2.1.0" 469 | } 470 | }, 471 | "isarray": { 472 | "version": "1.0.0", 473 | "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", 474 | "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=" 475 | }, 476 | "jmespath": { 477 | "version": "0.15.0", 478 | "resolved": "https://registry.npmjs.org/jmespath/-/jmespath-0.15.0.tgz", 479 | "integrity": "sha1-o/Iiqarp+Wb10nx5ZRDigJF2Qhc=" 480 | }, 481 | "lodash.defaults": { 482 | "version": "4.2.0", 483 | "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", 484 | "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" 485 | }, 486 | "lodash.flatten": { 487 | "version": "4.4.0", 488 | "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", 489 | "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" 490 | }, 491 | "ms": { 492 | "version": "2.1.2", 493 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 494 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 495 | }, 496 | "node-fetch": { 497 | "version": "2.6.1", 498 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 499 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" 500 | }, 501 | "object-assign": { 502 | "version": "4.1.1", 503 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 504 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 505 | }, 506 | "p-map": { 507 | "version": "2.1.0", 508 | "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", 509 | "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==" 510 | }, 511 | "punycode": { 512 | "version": "1.3.2", 513 | "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", 514 | "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=" 515 | }, 516 | "querystring": { 517 | "version": "0.2.0", 518 | "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", 519 | "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=" 520 | }, 521 | "redis-commands": { 522 | "version": "1.7.0", 523 | "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", 524 | "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" 525 | }, 526 | "redis-errors": { 527 | "version": "1.2.0", 528 | "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", 529 | "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=" 530 | }, 531 | "redis-parser": { 532 | "version": "3.0.0", 533 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", 534 | "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", 535 | "requires": { 536 | "redis-errors": "^1.0.0" 537 | } 538 | }, 539 | "sax": { 540 | "version": "1.2.1", 541 | "resolved": "https://registry.npmjs.org/sax/-/sax-1.2.1.tgz", 542 | "integrity": "sha1-e45lYZCyKOgaZq6nSEgNgozS03o=" 543 | }, 544 | "standard-as-callback": { 545 | "version": "2.1.0", 546 | "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", 547 | "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" 548 | }, 549 | "url": { 550 | "version": "0.10.3", 551 | "resolved": "https://registry.npmjs.org/url/-/url-0.10.3.tgz", 552 | "integrity": "sha1-Ah5NnHcF8hu/N9A861h2dAJ3TGQ=", 553 | "requires": { 554 | "punycode": "1.3.2", 555 | "querystring": "0.2.0" 556 | } 557 | }, 558 | "util-deprecate": { 559 | "version": "1.0.2", 560 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 561 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 562 | }, 563 | "uuid": { 564 | "version": "3.3.2", 565 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.2.tgz", 566 | "integrity": "sha512-yXJmeNaw3DnnKAOKJE51sL/ZaYfWJRl1pK9dr19YFCu0ObS231AB1/LbqTKRAQ5kw8A90rA6fr4riOUpTZvQZA==" 567 | }, 568 | "xml2js": { 569 | "version": "0.4.19", 570 | "resolved": "https://registry.npmjs.org/xml2js/-/xml2js-0.4.19.tgz", 571 | "integrity": "sha512-esZnJZJOiJR9wWKMyuvSE1y6Dq5LCuJanqhxslH2bxM6duahNZ+HMpCLhBQGZkbX6xRf8x1Y2eJlgt2q3qo49Q==", 572 | "requires": { 573 | "sax": ">=0.6.0", 574 | "xmlbuilder": "~9.0.1" 575 | } 576 | }, 577 | "xmlbuilder": { 578 | "version": "9.0.7", 579 | "resolved": "https://registry.npmjs.org/xmlbuilder/-/xmlbuilder-9.0.7.tgz", 580 | "integrity": "sha1-Ey7mPS7FVlxVfiD0wi35rKaGsQ0=" 581 | } 582 | } 583 | } 584 | -------------------------------------------------------------------------------- /initnewsdb/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "initmoviesdb", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "aws-sdk": "^2.864.0", 14 | "dotenv": "^8.2.0", 15 | "faunadb": "^4.1.1", 16 | "firebase-admin": "^9.11.1", 17 | "ioredis": "^4.24.2", 18 | "mongodb": "^4.0.1", 19 | "node-fetch": "^2.6.1" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /initnewsdb/query.gql: -------------------------------------------------------------------------------- 1 | query { 2 | graphql: redisLRange(key:"histogram-graphql", 3 | start: 0, stop: 100), 4 | redis: redisLRange(key:"histogram-redis", 5 | start: 0, stop: 100) 6 | dynamo: redisLRange(key:"histogram-dynamo", 7 | start: 0, stop: 100) 8 | fauna: redisLRange(key:"histogram-fauna", 9 | start: 0, stop: 100) 10 | 11 | } -------------------------------------------------------------------------------- /initnewsdb/reset.gql: -------------------------------------------------------------------------------- 1 | mutation { 2 | redisDel(keys: 3 | [ 4 | "histogram-redis", 5 | "histogram-fauna", 6 | "histogram-dynamo", 7 | "histogram-graphql", 8 | ]) 9 | } -------------------------------------------------------------------------------- /news-app/.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files/ for more about ignoring files. 2 | 3 | # dependencies 4 | /node_modules 5 | /.pnp 6 | .pnp.js 7 | 8 | # testing 9 | /coverage 10 | 11 | # production 12 | /build 13 | 14 | # misc 15 | .DS_Store 16 | .env.local 17 | .env.development.local 18 | .env.test.local 19 | .env.production.local 20 | 21 | npm-debug.log* 22 | yarn-debug.log* 23 | yarn-error.log* 24 | 25 | .vercel 26 | -------------------------------------------------------------------------------- /news-app/README.md: -------------------------------------------------------------------------------- 1 | # Getting Started with Create React App 2 | 3 | This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). 4 | 5 | ## Available Scripts 6 | 7 | In the project directory, you can run: 8 | 9 | ### `npm start` 10 | 11 | Runs the app in the development mode.\ 12 | Open [http://localhost:3000](http://localhost:3000) to view it in the browser. 13 | 14 | The page will reload if you make edits.\ 15 | You will also see any lint errors in the console. 16 | 17 | ### `npm test` 18 | 19 | Launches the test runner in the interactive watch mode.\ 20 | See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. 21 | 22 | ### `npm run build` 23 | 24 | Builds the app for production to the `build` folder.\ 25 | It correctly bundles React in production mode and optimizes the build for the best performance. 26 | 27 | The build is minified and the filenames include the hashes.\ 28 | Your app is ready to be deployed! 29 | 30 | See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. 31 | 32 | ### `npm run eject` 33 | 34 | **Note: this is a one-way operation. Once you `eject`, you can’t go back!** 35 | 36 | If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. 37 | 38 | Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. 39 | 40 | You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. 41 | 42 | ## Learn More 43 | 44 | You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). 45 | 46 | To learn React, check out the [React documentation](https://reactjs.org/). 47 | 48 | ### Code Splitting 49 | 50 | This section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting) 51 | 52 | ### Analyzing the Bundle Size 53 | 54 | This section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size) 55 | 56 | ### Making a Progressive Web App 57 | 58 | This section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app) 59 | 60 | ### Advanced Configuration 61 | 62 | This section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration) 63 | 64 | ### Deployment 65 | 66 | This section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment) 67 | 68 | ### `npm run build` fails to minify 69 | 70 | This section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify) 71 | -------------------------------------------------------------------------------- /news-app/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "news-app", 3 | "version": "0.1.0", 4 | "private": true, 5 | "dependencies": { 6 | "@testing-library/jest-dom": "^5.11.9", 7 | "@testing-library/react": "^11.2.5", 8 | "@testing-library/user-event": "^12.8.3", 9 | "react": "^17.0.2", 10 | "react-dom": "^17.0.2", 11 | "react-google-charts": "^3.0.15", 12 | "react-scripts": "4.0.3", 13 | "web-vitals": "^1.1.1" 14 | }, 15 | "scripts": { 16 | "start": "react-scripts start", 17 | "build": "react-scripts build", 18 | "test": "react-scripts test", 19 | "eject": "react-scripts eject" 20 | }, 21 | "eslintConfig": { 22 | "extends": [ 23 | "react-app", 24 | "react-app/jest" 25 | ] 26 | }, 27 | "browserslist": { 28 | "production": [ 29 | ">0.2%", 30 | "not dead", 31 | "not op_mini all" 32 | ], 33 | "development": [ 34 | "last 1 chrome version", 35 | "last 1 firefox version", 36 | "last 1 safari version" 37 | ] 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /news-app/public/cover-serverless-battleground.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/upstash/latency-comparison/a446a1a657afc7b825663c56093d9d26ff3d981e/news-app/public/cover-serverless-battleground.jpg -------------------------------------------------------------------------------- /news-app/public/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/upstash/latency-comparison/a446a1a657afc7b825663c56093d9d26ff3d981e/news-app/public/favicon.ico -------------------------------------------------------------------------------- /news-app/public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 17 | 18 | 22 | 23 | 32 | Live Latency Comparison Among Serverless Databases: MongoDB, Cassandra, Firestore, DynamoDB, FaunaDB, Upstash (Redis) 33 | 36 | 37 | 38 | 39 |
40 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /news-app/public/logo192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/upstash/latency-comparison/a446a1a657afc7b825663c56093d9d26ff3d981e/news-app/public/logo192.png -------------------------------------------------------------------------------- /news-app/public/logo512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/upstash/latency-comparison/a446a1a657afc7b825663c56093d9d26ff3d981e/news-app/public/logo512.png -------------------------------------------------------------------------------- /news-app/public/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "short_name": "React App", 3 | "name": "Create React App Sample", 4 | "icons": [ 5 | { 6 | "src": "favicon.ico", 7 | "sizes": "64x64 32x32 24x24 16x16", 8 | "type": "image/x-icon" 9 | }, 10 | { 11 | "src": "logo192.png", 12 | "type": "image/png", 13 | "sizes": "192x192" 14 | }, 15 | { 16 | "src": "logo512.png", 17 | "type": "image/png", 18 | "sizes": "512x512" 19 | } 20 | ], 21 | "start_url": ".", 22 | "display": "standalone", 23 | "theme_color": "#000000", 24 | "background_color": "#ffffff" 25 | } 26 | -------------------------------------------------------------------------------- /news-app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # https://www.robotstxt.org/robotstxt.html 2 | User-agent: * 3 | Disallow: 4 | -------------------------------------------------------------------------------- /news-app/src/App.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #fff; 3 | } 4 | 5 | .intro { 6 | width: 80%; 7 | line-height: 1.6; 8 | margin: auto; 9 | margin-top: 20px; 10 | background-color: #FAFAFA; 11 | color: #282c34; 12 | border: 1px solid #282c34; 13 | border-radius: 5px; 14 | padding: 1.5rem; 15 | font-size: 1.1rem; 16 | font-family: Menlo, Monaco, Lucida Console, Liberation Mono, DejaVu Sans Mono, 17 | Bitstream Vera Sans Mono, Courier New, monospace; 18 | } 19 | 20 | .newsImage { 21 | width: 180px; 22 | margin: 10px; 23 | } 24 | 25 | .newsDiv { 26 | border-bottom: 1px solid #aaa; 27 | padding: 10px; 28 | padding-top: 15px; 29 | padding-bottom: 15px; 30 | } 31 | 32 | .seelink { 33 | margin-left: 10px; 34 | margin-right: 10px; 35 | } 36 | 37 | a { 38 | color: #0070f3; 39 | } 40 | 41 | .reload { 42 | color: #0070f3; 43 | font-size: 16pt; 44 | font-weight: bold; 45 | margin-left: 10px; 46 | cursor: pointer; 47 | } 48 | 49 | .latencyTable { 50 | margin-top: 20px; 51 | } 52 | 53 | .latencyTable td { 54 | font-weight: bold; 55 | padding: 7px; 56 | font-size: 13pt; 57 | } 58 | 59 | .dbtd { 60 | text-align: left; 61 | } 62 | 63 | .tdlatency { 64 | text-align: right; 65 | font-size: 15pt; 66 | color: #0070f3; 67 | } 68 | 69 | .chartDiv { 70 | } -------------------------------------------------------------------------------- /news-app/src/App.js: -------------------------------------------------------------------------------- 1 | import './App.css'; 2 | import {useEffect, useState} from "react"; 3 | import {Chart} from "react-google-charts"; 4 | 5 | 6 | function App() { 7 | const [error, setError] = useState(null); 8 | const [isLoaded, setIsLoaded] = useState(false); 9 | const [redisLatency, setRedisLatency] = useState("?"); 10 | const [redismzLatency, setRedismzLatency] = useState("?"); 11 | const [redisrestLatency, setRedisrestLatency] = useState("?"); 12 | const [dynamoLatency, setDynamoLatency] = useState("?"); 13 | const [mongoLatency, setMongoLatency] = useState("?"); 14 | const [firestoreLatency, setFirestoreLatency] = useState("?"); 15 | const [faunaLatency, setFaunaLatency] = useState("?"); 16 | const [faunaUsLatency, setFaunaUsLatency] = useState("?"); 17 | const [cassandraLatency, setCassandraLatency] = useState("?"); 18 | const [latency50, setLatency50] = useState({redis: "?", dynamo: "?", fauna: "?", redismz: "?", redisrest: "?", mongo: "?", cassandra: "?", firestore: "?"}); 19 | const [latency99, setLatency99] = useState({redis: "?", dynamo: "?", fauna: "?", redismz: "?", redisrest: "?", mongo: "?", cassandra: "?", firestore: "?"}); 20 | const [latency999, setLatency999] = useState({redis: "?", dynamo: "?", fauna: "?", redismz: "?", redisrest: "?", mongo: "?", cassandra: "?", firestore: "?"}); 21 | const [items, setItems] = useState([]); 22 | const apiUrl = "https://nlm8ixxhud.execute-api.us-west-1.amazonaws.com/dev/" 23 | const apiUrlEast = "https://0s3ykqdj7a.execute-api.us-east-1.amazonaws.com/dev/" 24 | const apiUrlGCP = "https://us-central1-functions-317005.cloudfunctions.net/loadNews" 25 | 26 | function refreshPage() { 27 | window.location.reload(true); 28 | } 29 | 30 | useEffect(() => { 31 | let temp = [] 32 | const promises = [] 33 | promises.push(fetch(apiUrl + "redis") 34 | .then(res => res.json()) 35 | .then( 36 | (result) => { 37 | temp = temp.concat(result.data.Items) 38 | setRedisLatency(result.latency) 39 | }, 40 | (error) => { 41 | setIsLoaded(true); 42 | setError(error); 43 | } 44 | )) 45 | promises.push(fetch(apiUrl + "redismz") 46 | .then(res => res.json()) 47 | .then( 48 | (result) => { 49 | temp = temp.concat(result.data.Items) 50 | setRedismzLatency(result.latency) 51 | }, 52 | (error) => { 53 | setIsLoaded(true); 54 | setError(error); 55 | } 56 | )) 57 | promises.push(fetch(apiUrl + "redisrest") 58 | .then(res => res.json()) 59 | .then( 60 | (result) => { 61 | temp = temp.concat(result.data.Items) 62 | setRedisrestLatency(result.latency) 63 | }, 64 | (error) => { 65 | setIsLoaded(true); 66 | setError(error); 67 | } 68 | )) 69 | promises.push(fetch(apiUrl + "fauna") 70 | .then(res => res.json()) 71 | .then( 72 | (result) => { 73 | temp = temp.concat(result.data.Items) 74 | setFaunaLatency(result.latency) 75 | }, 76 | (error) => { 77 | setIsLoaded(true); 78 | setError(error); 79 | } 80 | )) 81 | promises.push(fetch(apiUrl + "faunaus") 82 | .then(res => res.json()) 83 | .then( 84 | (result) => { 85 | temp = temp.concat(result.data.Items) 86 | setFaunaUsLatency(result.latency) 87 | }, 88 | (error) => { 89 | setIsLoaded(true); 90 | setError(error); 91 | } 92 | )) 93 | promises.push(fetch(apiUrl + "dynamo") 94 | .then(res => res.json()) 95 | .then( 96 | (result) => { 97 | temp = temp.concat(result.data.Items) 98 | setDynamoLatency(result.latency) 99 | }, 100 | (error) => { 101 | setIsLoaded(true); 102 | setError(error); 103 | } 104 | )) 105 | promises.push(fetch(apiUrlEast + "mongo") 106 | .then(res => res.json()) 107 | .then( 108 | (result) => { 109 | temp = temp.concat(result.data.Items) 110 | setMongoLatency(result.latency) 111 | }, 112 | (error) => { 113 | setIsLoaded(true); 114 | setError(error); 115 | } 116 | )) 117 | promises.push(fetch(apiUrlGCP) 118 | .then(res => res.json()) 119 | .then( 120 | (result) => { 121 | temp = temp.concat(result.data.Items) 122 | setFirestoreLatency(result.latency) 123 | }, 124 | (error) => { 125 | setIsLoaded(true); 126 | setError(error); 127 | } 128 | )) 129 | promises.push(fetch(apiUrlEast + "cassandra") 130 | .then(res => res.json()) 131 | .then( 132 | (result) => { 133 | temp = temp.concat(result.data.Items) 134 | setCassandraLatency(result.latency) 135 | }, 136 | (error) => { 137 | setIsLoaded(true); 138 | setError(error); 139 | } 140 | )) 141 | fetch(apiUrl + "histogram") 142 | .then(res => res.json()) 143 | .then( 144 | (result) => { 145 | setLatency50({ 146 | redis: result.redis_histogram.p50, 147 | redismz: result.redismz_histogram.p50, 148 | redisrest: result.redisrest_histogram.p50, 149 | dynamodb: result.dynamo_histogram.p50, 150 | mongo: result.mongo_histogram.p50, 151 | firestore: result.firestore_histogram.p50, 152 | cassandra: result.cassandra_histogram.p50, 153 | faunaus: result.faunaus_histogram.p50, 154 | fauna: result.fauna_histogram.p50 155 | }) 156 | setLatency99({ 157 | redis: result.redis_histogram.p99, 158 | redismz: result.redismz_histogram.p99, 159 | redisrest: result.redisrest_histogram.p99, 160 | dynamodb: result.dynamo_histogram.p99, 161 | mongo: result.mongo_histogram.p99, 162 | firestore: result.firestore_histogram.p99, 163 | cassandra: result.cassandra_histogram.p99, 164 | faunaus: result.faunaus_histogram.p99, 165 | fauna: result.fauna_histogram.p99 166 | }) 167 | setLatency999({ 168 | redis: result.redis_histogram.p99_9, 169 | redismz: result.redismz_histogram.p99_9, 170 | redisrest: result.redisrest_histogram.p99_9, 171 | dynamodb: result.dynamo_histogram.p99_9, 172 | mongo: result.mongo_histogram.p99_9, 173 | firestore: result.firestore_histogram.p99_9, 174 | cassandra: result.cassandra_histogram.p99_9, 175 | faunaus: result.faunaus_histogram.p99_9, 176 | fauna: result.fauna_histogram.p99_9 177 | }) 178 | } 179 | ) 180 | Promise.all(promises).then(() => { 181 | setIsLoaded(true); 182 | setItems(temp) 183 | } 184 | ) 185 | }, []) 186 | 187 | 188 | let news; 189 | if (error) { 190 | news =
Error: {error.message}
; 191 | } else if (!isLoaded) { 192 | news =
Loading...
; 193 | } else { 194 | news = ( 195 |
196 | {items.map(item => ( 197 |
198 |
199 | 200 |
201 |
202 | 203 | {item.headline} 204 | 205 |
206 | {item.abstract} 207 |
208 |
209 | ))} 210 |
211 | ); 212 | } 213 | return ( 214 |
215 |

Live Latency Comparison Among Serverless Databases

216 | This single page application compares the latencies of leading serverless databases ( 217 | 218 | DynamoDB, 219 | 220 | {" "} 221 | 222 | MongoDB (Atlas), 223 | 224 | {" "} 225 | 226 | Firestore, 227 | 228 | {" "} 229 | 230 | Cassandra (Datastax Astra), 231 | 232 | {" "} 233 | 234 | FaunaDB, 235 | 236 | {" "} 237 | 238 | Redis (Upstash) 239 | ) 240 | for a common web usecase. 241 |
242 |
243 | I have inserted 7001 news articles into each database. The articles are collected from {' '} 244 | 245 | New York Times Archive API 246 | (all articles of January 2021). 247 | I randomly scored each news article. At each page request, I query top 10 248 | articles under `World` section from each database. 249 |
250 |
251 | I use serverless functions (AWS Lambda) to load the articles from each database. Response time of 252 | fetching 10 articles is being recorded as latency inside the lambda function. 253 |
254 |
255 | Here the latency of the current request: 256 | 257 | ⟳ 258 | 259 |
260 | DynamoDB: {Math.round(dynamoLatency)} ms | 261 | Cassandra: {Math.round(cassandraLatency)} ms | 262 | Firestore: {Math.round(firestoreLatency)} ms | 263 | MongoDB: {Math.round(mongoLatency)} ms | 264 | FaunaDB: {Math.round(faunaLatency)} ms | 265 | FaunaDB (US Region): {Math.round(faunaUsLatency)} ms | 266 | Upstash: {Math.round(redisLatency)} ms | 267 | Upstash Multizone: {Math.round(redismzLatency)} ms | 268 | Upstash REST: {Math.round(redisrestLatency)} ms 269 |
270 |
271 | See the blog post 272 | for the details. 273 |
274 |
275 | The latency numbers so far: 276 |
277 |
278 |
279 |
280 |
281 | 50th Percentile (latency in milliseconds): 282 | Loading Chart
} 285 | data={[ 286 | ['Database', 'p50 latency (ms)', {role: 'style'}, {role: 'annotation'}], 287 | ['DynamoDB', latency50.dynamodb, "#D96C2D", latency50.dynamodb], 288 | ['Cassandra', latency50.cassandra, "#4F97E1", latency50.cassandra], 289 | ['Firestore', latency50.firestore, "#469454", latency50.firestore], 290 | ['MongoDB', latency50.mongo, "#469454", latency50.mongo], 291 | ['FaunaDB', latency50.fauna, "#39059E", latency50.fauna], 292 | ['FaunaDB US', latency50.faunaus, "#3905CE", latency50.faunaus], 293 | ['Upstash', latency50.redis, "#6BE5A8", latency50.redis], 294 | ['Upstash Multizone', latency50.redismz, "#6BE5A8", latency50.redismz], 295 | ['Upstash REST', latency50.redisrest, "#6BE5A8", latency50.redisrest], 296 | ]} 297 | options={{ 298 | title: '50 Percentile Latency in Milliseconds', 299 | titlePosition: 'none', 300 | chartArea: {left: 60, width: '60%'}, 301 | hAxis: { 302 | minValue: 0, 303 | }, 304 | backgroundColor: '#FAFAFA', 305 | legend: {position: 'none'}, 306 | vAxis: { 307 | title: 'milliseconds', 308 | }, 309 | }} 310 | /> 311 |
312 |
313 | 99th Percentile (latency in milliseconds): 314 | Loading Chart
} 317 | data={[ 318 | ['Database', 'p99 latency (ms)', {role: 'style'}, {role: 'annotation'}], 319 | ['DynamoDB', latency99.dynamodb, "#D96C2D", latency99.dynamodb], 320 | ['Cassandra', latency99.cassandra, "#4F97E1", latency99.cassandra], 321 | ['Firestore', latency99.firestore, "#469454", latency99.firestore], 322 | ['MongoDB', latency99.mongo, "#469454", latency99.mongo], 323 | ['FaunaDB', latency99.fauna, "#39059E", latency99.fauna], 324 | ['FaunaDB US', latency99.faunaus, "#3905CE", latency99.faunaus], 325 | ['Upstash', latency99.redis, "#6BE5A8", latency99.redis], 326 | ['Upstash Multizone', latency99.redismz, "#6BE5A8", latency99.redismz], 327 | ['Upstash REST', latency99.redisrest, "#6BE5A8", latency99.redisrest], 328 | ]} 329 | options={{ 330 | title: '99 Percentile Latency in Milliseconds', 331 | titlePosition: 'none', 332 | chartArea: {left: 60, width: '60%'}, 333 | hAxis: { 334 | minValue: 0, 335 | }, 336 | backgroundColor: '#FAFAFA', 337 | legend: {position: 'none'}, 338 | vAxis: { 339 | title: 'milliseconds', 340 | }, 341 | }} 342 | /> 343 |
344 |
345 | 99.9th Percentile (latency in milliseconds): 346 | Loading Chart
} 349 | data={[ 350 | ['Database', 'p99.9 latency (ms)', {role: 'style'}, {role: 'annotation'}], 351 | ['DynamoDB', latency999.dynamodb, "#D96C2D", latency999.dynamodb], 352 | ['Cassandra', latency999.cassandra, "#4F97E1", latency999.cassandra], 353 | ['Firestore', latency999.firestore, "#469454", latency999.firestore], 354 | ['MongoDB', latency999.mongo, "#469454", latency999.mongo], 355 | ['FaunaDB', latency999.fauna, "#39059E", latency999.fauna], 356 | ['FaunaDB US', latency99.faunaus, "#3905CE", latency999.faunaus], 357 | ['Upstash', latency999.redis, "#6BE5A8", latency999.redis], 358 | ['Upstash Multizone', latency999.redismz, "#6BE5A8", latency999.redismz], 359 | ['Upstash REST', latency999.redisrest, "#6BE5A8", latency999.redisrest], 360 | ]} 361 | options={{ 362 | title: '99.9 Percentile Latency in Milliseconds', 363 | titlePosition: 'none', 364 | chartArea: {left: 60, width: '60%'}, 365 | hAxis: { 366 | minValue: 0, 367 | }, 368 | backgroundColor: '#FAFAFA', 369 | legend: {position: 'none'}, 370 | vAxis: { 371 | title: 'milliseconds', 372 | }, 373 | }} 374 | /> 375 |
376 | 377 | 378 | 379 | 380 | 381 |
382 | See 383 | 385 | the full histogram 386 | 387 | | 388 | 389 | the blog post 390 | 391 | | 392 | 393 | the source code 394 | 395 |
396 |
397 | Enjoy the news! 398 |
399 | {news} 400 | 401 | ); 402 | } 403 | 404 | export default App; 405 | -------------------------------------------------------------------------------- /news-app/src/App.test.js: -------------------------------------------------------------------------------- 1 | import { render, screen } from '@testing-library/react'; 2 | import App from './App'; 3 | 4 | test('renders learn react link', () => { 5 | render(); 6 | const linkElement = screen.getByText(/learn react/i); 7 | expect(linkElement).toBeInTheDocument(); 8 | }); 9 | -------------------------------------------------------------------------------- /news-app/src/index.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 4 | 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', 5 | sans-serif; 6 | -webkit-font-smoothing: antialiased; 7 | -moz-osx-font-smoothing: grayscale; 8 | } 9 | 10 | code { 11 | font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', 12 | monospace; 13 | } 14 | -------------------------------------------------------------------------------- /news-app/src/index.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import ReactDOM from 'react-dom'; 3 | import './index.css'; 4 | import App from './App'; 5 | import reportWebVitals from './reportWebVitals'; 6 | 7 | ReactDOM.render( 8 | 9 | 10 | , 11 | document.getElementById('root') 12 | ); 13 | 14 | // If you want to start measuring performance in your app, pass a function 15 | // to log results (for example: reportWebVitals(console.log)) 16 | // or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals 17 | reportWebVitals(); 18 | -------------------------------------------------------------------------------- /news-app/src/logo.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /news-app/src/old.css: -------------------------------------------------------------------------------- 1 | .App { 2 | text-align: center; 3 | } 4 | 5 | .App-logo { 6 | height: 40vmin; 7 | pointer-events: none; 8 | } 9 | 10 | @media (prefers-reduced-motion: no-preference) { 11 | .App-logo { 12 | animation: App-logo-spin infinite 20s linear; 13 | } 14 | } 15 | 16 | .App-header { 17 | background-color: #282c34; 18 | min-height: 100vh; 19 | display: flex; 20 | flex-direction: column; 21 | align-items: center; 22 | justify-content: center; 23 | font-size: calc(10px + 2vmin); 24 | color: white; 25 | } 26 | 27 | .App-link { 28 | color: #61dafb; 29 | } 30 | 31 | @keyframes App-logo-spin { 32 | from { 33 | transform: rotate(0deg); 34 | } 35 | to { 36 | transform: rotate(360deg); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /news-app/src/reportWebVitals.js: -------------------------------------------------------------------------------- 1 | const reportWebVitals = onPerfEntry => { 2 | if (onPerfEntry && onPerfEntry instanceof Function) { 3 | import('web-vitals').then(({ getCLS, getFID, getFCP, getLCP, getTTFB }) => { 4 | getCLS(onPerfEntry); 5 | getFID(onPerfEntry); 6 | getFCP(onPerfEntry); 7 | getLCP(onPerfEntry); 8 | getTTFB(onPerfEntry); 9 | }); 10 | } 11 | }; 12 | 13 | export default reportWebVitals; 14 | -------------------------------------------------------------------------------- /news-app/src/setupTests.js: -------------------------------------------------------------------------------- 1 | // jest-dom adds custom jest matchers for asserting on DOM nodes. 2 | // allows you to do things like: 3 | // expect(element).toHaveTextContent(/react/i) 4 | // learn more: https://github.com/testing-library/jest-dom 5 | import '@testing-library/jest-dom'; 6 | -------------------------------------------------------------------------------- /newsapis/.gitignore: -------------------------------------------------------------------------------- 1 | # package directories 2 | node_modules 3 | jspm_packages 4 | 5 | serverless.yml 6 | # Serverless directories 7 | .serverless -------------------------------------------------------------------------------- /newsapis/cassandraHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Redis = require("ioredis"); 4 | const fetch = require("node-fetch"); 5 | const { performance } = require("perf_hooks"); 6 | 7 | module.exports.load = async (event) => { 8 | let start = performance.now(); 9 | let url = 'https://5864e932-14a7-4335-8d84-16f40e451b5b-us-east-1.apps.astra.datastax.com/api/rest/v2/keyspaces/news/items?page-size=10&sort={"view_count":"desc"}&view_count&where={"section":{"$eq":"World"}}'; 10 | let data = await fetch(url, { 11 | method: 'GET', // *GET, POST, PUT, DELETE, etc. 12 | headers: { 13 | 'Content-Type': 'application/json', 14 | 'x-cassandra-token': process.env.CASSANDRA_TOKEN 15 | } 16 | }) 17 | data = await data.json() 18 | let dd = data.data 19 | let items = [] 20 | for(let i = 0; i < dd.length; i++) { 21 | items.push(dd[i]); 22 | } 23 | // response is ready so we can set the latency 24 | let latency = performance.now() - start; 25 | 26 | 27 | // pushing the latency to the histogram 28 | const client2 = new Redis(process.env.LATENCY_REDIS_URL); 29 | await client2.lpush("histogram-cassandra", latency) 30 | await client2.quit(); 31 | 32 | return { 33 | statusCode: 200, 34 | headers: { 35 | 'Access-Control-Allow-Origin': '*', 36 | 'Access-Control-Allow-Credentials': true, 37 | }, 38 | body: JSON.stringify( { 39 | latency: latency, 40 | data: { 41 | Items: items 42 | }, 43 | }) 44 | }; 45 | }; 46 | -------------------------------------------------------------------------------- /newsapis/dynamoHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var AWS = require("aws-sdk"); 4 | AWS.config.update({ 5 | region: "us-west-1" 6 | }); 7 | const https = require('https'); 8 | const agent = new https.Agent({ 9 | keepAlive: true, 10 | maxSockets: Infinity 11 | }); 12 | 13 | AWS.config.update({ 14 | httpOptions: { 15 | agent 16 | } 17 | }); 18 | 19 | const Redis = require("ioredis"); 20 | const { performance } = require("perf_hooks"); 21 | const tableName = "news"; 22 | var params = { 23 | TableName: tableName, 24 | IndexName: "section-view_count-index", 25 | KeyConditionExpression: "#sect = :section", 26 | ExpressionAttributeNames: { 27 | "#sect": "section" 28 | }, 29 | ExpressionAttributeValues: { 30 | ":section": process.env.SECTION 31 | }, 32 | Limit: 10, 33 | ScanIndexForward: false, 34 | }; 35 | const docClient = new AWS.DynamoDB.DocumentClient(); 36 | 37 | module.exports.load = (event, context, callback) => { 38 | let start = performance.now(); 39 | docClient.query(params, (err, result) => { 40 | if (err) { 41 | console.error("Unable to scan the table. Error JSON:", JSON.stringify(err, null, 2)); 42 | } else { 43 | // response is ready so we can set the latency 44 | let latency = performance.now() - start; 45 | let response = { 46 | statusCode: 200, 47 | headers: { 48 | 'Access-Control-Allow-Origin': '*', 49 | 'Access-Control-Allow-Credentials': true, 50 | }, 51 | body: JSON.stringify( 52 | { 53 | latency: latency, 54 | data: result, 55 | } 56 | ) 57 | }; 58 | // we are setting random score to top-10 items to simulate real time dynamic data 59 | result.Items.forEach(item =>{ 60 | let view_count = Math.floor(Math.random() * 1000); 61 | var params2 = { 62 | TableName:tableName, 63 | Key:{ 64 | "id": item.id, 65 | }, 66 | UpdateExpression: "set view_count = :r", 67 | ExpressionAttributeValues:{ 68 | ":r":view_count 69 | }, 70 | }; 71 | docClient.update(params2, function(err, data) { 72 | if (err) { 73 | console.error("Unable to update item. Error JSON:", JSON.stringify(err, null, 2)); 74 | } 75 | }); 76 | } ); 77 | // pushing the latency to the histogram 78 | const client = new Redis(process.env.LATENCY_REDIS_URL); 79 | client.lpush("histogram-dynamo", latency, (resp) => { 80 | client.quit(); 81 | callback(null, response) 82 | }) 83 | } 84 | }); 85 | }; 86 | -------------------------------------------------------------------------------- /newsapis/faunaHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const faunadb = require("faunadb"); 4 | const Redis = require("ioredis"); 5 | const { performance } = require("perf_hooks"); 6 | const q = faunadb.query 7 | const client = new faunadb.Client({ 8 | secret: process.env.FAUNA_SECRET, 9 | keepAlive: true 10 | }) 11 | const section = process.env.SECTION; 12 | 13 | module.exports.load = async (event) => { 14 | let start = performance.now(); 15 | let ret = await client.query( 16 | // the below is Fauna API for "select from news where section = 'world' order by view_count limit 10" 17 | q.Map(q.Paginate(q.Match(q.Index('section_by_view_count'), section), {size: 10}), q.Lambda(["view_count", "X"], q.Get(q.Var("X")))) 18 | ).catch((err) => console.error('Error: %s', err)) 19 | // response is ready so we can set the latency 20 | let latency = performance.now() - start; 21 | const rclient = new Redis(process.env.LATENCY_REDIS_URL); 22 | await rclient.lpush("histogram-fauna", latency) 23 | await rclient.quit(); 24 | 25 | let result = []; 26 | for (let i = 0; i < ret.data.length; i++) { 27 | result.push(ret.data[i].data) 28 | } 29 | 30 | // we are setting random scores to top-10 items asynchronously to simulate real time dynamic data 31 | /* Evan Weaver suggested to skip this section. https://news.ycombinator.com/item?id=26799074 32 | ret.data.forEach((item) => { 33 | let view_count = Math.floor(Math.random() * 1000); 34 | client.query( 35 | q.Update( 36 | q.Ref(q.Collection('news'), item["ref"].id), 37 | {data: {view_count}}, 38 | ) 39 | ).catch((err) => console.error('Error: %s', err)) 40 | }) 41 | */ 42 | 43 | return { 44 | statusCode: 200, 45 | headers: { 46 | 'Access-Control-Allow-Origin': '*', 47 | 'Access-Control-Allow-Credentials': true, 48 | }, 49 | body: JSON.stringify({ 50 | latency: latency, 51 | data: { 52 | Items: result 53 | }, 54 | }) 55 | }; 56 | }; -------------------------------------------------------------------------------- /newsapis/faunaUsHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const faunadb = require("faunadb"); 4 | const Redis = require("ioredis"); 5 | const { performance } = require("perf_hooks"); 6 | const q = faunadb.query 7 | const client = new faunadb.Client({ 8 | secret: process.env.FAUNA_US_SECRET, 9 | domain: 'db.us.fauna.com', 10 | keepAlive: true 11 | }) 12 | const section = process.env.SECTION; 13 | 14 | module.exports.load = async (event) => { 15 | let start = performance.now(); 16 | let ret = await client.query( 17 | // the below is Fauna API for "select from news where section = 'world' order by view_count limit 10" 18 | q.Map(q.Paginate(q.Match(q.Index('section_by_view_count'), section), {size: 10}), q.Lambda(["view_count", "X"], q.Get(q.Var("X")))) 19 | ).catch((err) => console.error('Error: %s', err)) 20 | // response is ready so we can set the latency 21 | let latency = performance.now() - start; 22 | const rclient = new Redis(process.env.LATENCY_REDIS_URL); 23 | await rclient.lpush("histogram-fauna-us", latency) 24 | await rclient.quit(); 25 | 26 | let result = []; 27 | for (let i = 0; i < ret.data.length; i++) { 28 | result.push(ret.data[i].data) 29 | } 30 | 31 | // we are setting random scores to top-10 items asynchronously to simulate real time dynamic data 32 | /* Evan Weaver suggested to skip this section. https://news.ycombinator.com/item?id=26799074 33 | ret.data.forEach((item) => { 34 | let view_count = Math.floor(Math.random() * 1000); 35 | client.query( 36 | q.Update( 37 | q.Ref(q.Collection('news'), item["ref"].id), 38 | {data: {view_count}}, 39 | ) 40 | ).catch((err) => console.error('Error: %s', err)) 41 | }) 42 | */ 43 | 44 | return { 45 | statusCode: 200, 46 | headers: { 47 | 'Access-Control-Allow-Origin': '*', 48 | 'Access-Control-Allow-Credentials': true, 49 | }, 50 | body: JSON.stringify({ 51 | latency: latency, 52 | data: { 53 | Items: result 54 | }, 55 | }) 56 | }; 57 | }; -------------------------------------------------------------------------------- /newsapis/gcp/index.js: -------------------------------------------------------------------------------- 1 | 2 | const admin = require('firebase-admin'); 3 | const { performance } = require("perf_hooks"); 4 | const Redis = require("ioredis"); 5 | 6 | admin.initializeApp(); 7 | const db = admin.firestore(); 8 | 9 | 10 | exports.loadNews = async(req, res) => { 11 | let start = performance.now(); 12 | const snapshot = await db.collection("news").where('section', '==', 'World') 13 | .orderBy('view_count', 'desc').limit(10).get(); 14 | let latency = performance.now() - start; 15 | 16 | snapshot.forEach(doc => { 17 | let view_count = Math.floor(Math.random() * 1000); 18 | const newsRef = db.collection('news').doc(doc.id); 19 | newsRef.update({view_count: view_count}); 20 | }); 21 | 22 | const client = new Redis(process.env.LATENCY_REDIS_URL); 23 | await client.lpush("histogram-firestore", latency, (resp) => { 24 | client.quit(); 25 | }) 26 | 27 | if (snapshot.empty) { 28 | console.log('No matching documents.'); 29 | res.send('No matching documents.'); 30 | } else { 31 | var docs = snapshot.docs.map(doc => doc.data()); 32 | res.set('Access-Control-Allow-Origin', "*") 33 | res.set('Access-Control-Allow-Credentials', true); 34 | res.json({ latency: latency, data : {Items: docs } }); 35 | } 36 | }; 37 | 38 | 39 | // gcloud config set project functions-317005 40 | // gcloud functions deploy loadNews --runtime nodejs14 --trigger-http --allow-unauthenticated -------------------------------------------------------------------------------- /newsapis/gcp/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gcp", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "dotenv": "^8.2.0", 13 | "firebase-admin": "^9.11.1", 14 | "ioredis": "^4.24.2" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /newsapis/histogramHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Redis = require("ioredis"); 4 | const hdr = require("hdr-histogram-js"); 5 | 6 | module.exports.load = async (event) => { 7 | const client = new Redis(process.env.LATENCY_REDIS_URL); 8 | let dataMongo = await client.lrange("histogram-mongo", 0, 10000) 9 | let dataFirestore = await client.lrange("histogram-firestore", 0, 10000) 10 | let dataCassandra = await client.lrange("histogram-cassandra", 0, 10000) 11 | let dataRedis = await client.lrange("histogram-redis", 0, 10000) 12 | let dataRedismz = await client.lrange("histogram-redismz", 0, 10000) 13 | let dataRedisrest = await client.lrange("histogram-redisrest", 0, 10000) 14 | let dataDynamo = await client.lrange("histogram-dynamo", 0, 10000) 15 | let dataFauna = await client.lrange("histogram-fauna", 0, 10000) 16 | let dataFaunaUs = await client.lrange("histogram-fauna-us", 0, 10000) 17 | let dataGlobal = await client.lrange("histogram-global", 0, 10000) 18 | let dataEdgeE = await client.lrange("histogram-edgeEnabled", 0, 10000) 19 | let dataEdgeD = await client.lrange("histogram-edgeDisabled", 0, 10000) 20 | const hmongo = hdr.build(); 21 | const hfirestore = hdr.build(); 22 | const hcassandra = hdr.build(); 23 | const hredis = hdr.build(); 24 | const hredismz = hdr.build(); 25 | const hredisrest = hdr.build(); 26 | const hdynamo = hdr.build(); 27 | const hfauna = hdr.build(); 28 | const hfaunaus = hdr.build(); 29 | const hglobal = hdr.build(); 30 | const hedgee = hdr.build(); 31 | const hedged = hdr.build(); 32 | dataRedis.forEach(item => { 33 | hredis.recordValue(item); 34 | }) 35 | dataCassandra.forEach(item => { 36 | hcassandra.recordValue(item); 37 | }) 38 | dataMongo.forEach(item => { 39 | hmongo.recordValue(item); 40 | }) 41 | dataFirestore.forEach(item => { 42 | hfirestore.recordValue(item); 43 | }) 44 | dataRedismz.forEach(item => { 45 | hredismz.recordValue(item); 46 | }) 47 | dataRedisrest.forEach(item => { 48 | hredisrest.recordValue(item); 49 | }) 50 | dataDynamo.forEach(item => { 51 | hdynamo.recordValue(item); 52 | }) 53 | dataFauna.forEach(item => { 54 | hfauna.recordValue(item); 55 | }) 56 | dataFaunaUs.forEach(item => { 57 | hfaunaus.recordValue(item); 58 | }) 59 | dataGlobal.forEach(item => { 60 | hglobal.recordValue(item); 61 | }) 62 | dataEdgeE.forEach(item => { 63 | hedgee.recordValue(item); 64 | }) 65 | dataEdgeD.forEach(item => { 66 | hedged.recordValue(item); 67 | }) 68 | await client.quit(); 69 | hredis.maxValue = null 70 | hmongo.maxValue = null 71 | hfirestore.maxValue = null 72 | hcassandra.maxValue = null 73 | hredismz.maxValue = null 74 | hredisrest.maxValue = null 75 | hfauna.maxValue = null 76 | hfaunaus.maxValue = null 77 | hglobal.maxValue = null 78 | hdynamo.maxValue = null 79 | hedgee.maxValue = null 80 | hedged.maxValue = null 81 | return { 82 | statusCode: 200, 83 | headers: { 84 | 'Access-Control-Allow-Origin': '*', 85 | 'Access-Control-Allow-Credentials': true, 86 | }, 87 | body: JSON.stringify( 88 | { 89 | redis_min: hredis.minNonZeroValue, 90 | mongo_min: hmongo.minNonZeroValue, 91 | firestore_min: hfirestore.minNonZeroValue, 92 | cassandra_min: hcassandra.minNonZeroValue, 93 | redismz_min: hredismz.minNonZeroValue, 94 | redisrest_min: hredisrest.minNonZeroValue, 95 | dynamo_min: hdynamo.minNonZeroValue, 96 | fauna_min: hfauna.minNonZeroValue, 97 | faunaus_min: hfaunaus.minNonZeroValue, 98 | global_min: hglobal.minNonZeroValue, 99 | edgee_min: hedgee.minNonZeroValue, 100 | edged_min: hedged.minNonZeroValue, 101 | redis_mean: hredis.mean, 102 | mongo_mean: hmongo.mean, 103 | firestore_mean: hfirestore.mean, 104 | cassandra_mean: hcassandra.mean, 105 | redismz_mean: hredismz.mean, 106 | redisrest_mean: hredisrest.mean, 107 | dynamo_mean: hdynamo.mean, 108 | fauna_mean: hfauna.mean, 109 | faunaus_mean: hfaunaus.mean, 110 | global_mean: hglobal.mean, 111 | edgee_mean: hedgee.mean, 112 | edged_mean: hedged.mean, 113 | redis_histogram: hredis, 114 | mongo_histogram: hmongo, 115 | firestore_histogram: hfirestore, 116 | cassandra_histogram: hcassandra, 117 | redismz_histogram: hredismz, 118 | redisrest_histogram: hredisrest, 119 | dynamo_histogram: hdynamo, 120 | fauna_histogram: hfauna, 121 | faunaus_histogram: hfaunaus, 122 | global_histogram: hglobal, 123 | edgee_histogram: hedgee, 124 | edged_histogram: hedged, 125 | }, 126 | null, 127 | 2 128 | ) 129 | }; 130 | }; 131 | -------------------------------------------------------------------------------- /newsapis/mongoHandler.js: -------------------------------------------------------------------------------- 1 | // Import the MongoDB driver 2 | const MongoClient = require("mongodb").MongoClient; 3 | const { performance } = require("perf_hooks"); 4 | const Redis = require("ioredis"); 5 | 6 | // Once we connect to the database once, we'll store that connection and reuse it so that we don't have to connect to the database on every request. 7 | let cachedDb = null; 8 | 9 | async function connectToDatabase() { 10 | if (cachedDb) { 11 | return cachedDb; 12 | } 13 | 14 | // Connect to our MongoDB database hosted on MongoDB Atlas 15 | const client = await MongoClient.connect(process.env.MONGO_URL); 16 | 17 | // Specify which database we want to use 18 | const db = await client.db("news"); 19 | 20 | cachedDb = db; 21 | return db; 22 | } 23 | 24 | module.exports.load = async (event, context) => { 25 | 26 | /* By default, the callback waits until the runtime event loop is empty before freezing the process and returning the results to the caller. Setting this property to false requests that AWS Lambda freeze the process soon after the callback is invoked, even if there are events in the event loop. AWS Lambda will freeze the process, any state data, and the events in the event loop. Any remaining events in the event loop are processed when the Lambda function is next invoked, if AWS Lambda chooses to use the frozen process. */ 27 | context.callbackWaitsForEmptyEventLoop = false; 28 | 29 | // Get an instance of our database 30 | const db = await connectToDatabase(); 31 | 32 | let start = performance.now(); 33 | // Make a MongoDB MQL Query to go into the movies collection and return the first 20 movies. 34 | const news = await db.collection("news").find({"section":"World"}).sort({"view_count":-1}).limit(10).toArray(); 35 | let latency = performance.now() - start; 36 | 37 | news.forEach(item =>{ 38 | let view_count = Math.floor(Math.random() * 1000); 39 | db.collection("news").updateOne( 40 | {"_id" : item._id}, 41 | {$set: { "view_count" : view_count}}); 42 | } ); 43 | 44 | const client = new Redis(process.env.LATENCY_REDIS_URL); 45 | await client.lpush("histogram-mongo", latency, (resp) => { 46 | client.quit(); 47 | }) 48 | 49 | const response = { 50 | statusCode: 200, 51 | headers: { 52 | 'Access-Control-Allow-Origin': '*', 53 | 'Access-Control-Allow-Credentials': true, 54 | }, 55 | body: JSON.stringify({ 56 | latency: latency, 57 | data: {Items: news}, 58 | }), 59 | }; 60 | 61 | return response; 62 | }; -------------------------------------------------------------------------------- /newsapis/package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "newsapis", 3 | "version": "1.0.0", 4 | "lockfileVersion": 2, 5 | "requires": true, 6 | "packages": { 7 | "": { 8 | "version": "1.0.0", 9 | "license": "ISC", 10 | "dependencies": { 11 | "faunadb": "^4.1.2", 12 | "hdr-histogram-js": "^2.0.1", 13 | "ioredis": "^4.24.2" 14 | } 15 | }, 16 | "node_modules/@assemblyscript/loader": { 17 | "version": "0.10.1", 18 | "resolved": "https://registry.npmjs.org/@assemblyscript/loader/-/loader-0.10.1.tgz", 19 | "integrity": "sha512-H71nDOOL8Y7kWRLqf6Sums+01Q5msqBW2KhDUTemh1tvY04eSkSXrK0uj/4mmY0Xr16/3zyZmsrxN7CKuRbNRg==" 20 | }, 21 | "node_modules/abort-controller": { 22 | "version": "3.0.0", 23 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", 24 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", 25 | "dependencies": { 26 | "event-target-shim": "^5.0.0" 27 | }, 28 | "engines": { 29 | "node": ">=6.5" 30 | } 31 | }, 32 | "node_modules/base64-js": { 33 | "version": "1.5.1", 34 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 35 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" 36 | }, 37 | "node_modules/btoa-lite": { 38 | "version": "1.0.0", 39 | "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", 40 | "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" 41 | }, 42 | "node_modules/cluster-key-slot": { 43 | "version": "1.1.0", 44 | "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", 45 | "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==", 46 | "engines": { 47 | "node": ">=0.10.0" 48 | } 49 | }, 50 | "node_modules/cross-fetch": { 51 | "version": "3.1.2", 52 | "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.2.tgz", 53 | "integrity": "sha512-+JhD65rDNqLbGmB3Gzs3HrEKC0aQnD+XA3SY6RjgkF88jV2q5cTc5+CwxlS3sdmLk98gpPt5CF9XRnPdlxZe6w==", 54 | "dependencies": { 55 | "node-fetch": "2.6.1" 56 | } 57 | }, 58 | "node_modules/debug": { 59 | "version": "4.3.1", 60 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", 61 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", 62 | "dependencies": { 63 | "ms": "2.1.2" 64 | }, 65 | "engines": { 66 | "node": ">=6.0" 67 | } 68 | }, 69 | "node_modules/denque": { 70 | "version": "1.5.0", 71 | "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", 72 | "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==", 73 | "engines": { 74 | "node": ">=0.10" 75 | } 76 | }, 77 | "node_modules/dotenv": { 78 | "version": "8.2.0", 79 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", 80 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==", 81 | "engines": { 82 | "node": ">=8" 83 | } 84 | }, 85 | "node_modules/event-target-shim": { 86 | "version": "5.0.1", 87 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", 88 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", 89 | "engines": { 90 | "node": ">=6" 91 | } 92 | }, 93 | "node_modules/faunadb": { 94 | "version": "4.1.2", 95 | "resolved": "https://registry.npmjs.org/faunadb/-/faunadb-4.1.2.tgz", 96 | "integrity": "sha512-NJn9LBf/63ZD3i9bPAz8uBMvEXmnkfsPHn5AGMD8WBvKfJ4NaQ0AXadTK0NItVHvcZPIIqyc5BlgskveTNB+bA==", 97 | "dependencies": { 98 | "abort-controller": "^3.0.0", 99 | "base64-js": "^1.2.0", 100 | "btoa-lite": "^1.0.0", 101 | "cross-fetch": "^3.0.6", 102 | "dotenv": "^8.2.0", 103 | "fn-annotate": "^1.1.3", 104 | "object-assign": "^4.1.0", 105 | "util-deprecate": "^1.0.2" 106 | } 107 | }, 108 | "node_modules/fn-annotate": { 109 | "version": "1.2.0", 110 | "resolved": "https://registry.npmjs.org/fn-annotate/-/fn-annotate-1.2.0.tgz", 111 | "integrity": "sha1-KNoAARfephhC/mHzU/Qc9Mk6en4=", 112 | "engines": { 113 | "node": ">=0.10.0" 114 | } 115 | }, 116 | "node_modules/hdr-histogram-js": { 117 | "version": "2.0.1", 118 | "resolved": "https://registry.npmjs.org/hdr-histogram-js/-/hdr-histogram-js-2.0.1.tgz", 119 | "integrity": "sha512-uPZxl1dAFnjUFHWLZmt93vUUvtHeaBay9nVNHu38SdOjMSF/4KqJUqa1Seuj08ptU1rEb6AHvB41X8n/zFZ74Q==", 120 | "dependencies": { 121 | "@assemblyscript/loader": "^0.10.1", 122 | "base64-js": "^1.2.0", 123 | "pako": "^1.0.3" 124 | } 125 | }, 126 | "node_modules/ioredis": { 127 | "version": "4.24.2", 128 | "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-4.24.2.tgz", 129 | "integrity": "sha512-SSuVXwoG747sZetxxs9gyAno5kfUfvo4s5mSZp4dh8vzuTnrtA5mTf2OjL6sPfIfNbVTROg2c+VbXceGlpucPQ==", 130 | "dependencies": { 131 | "cluster-key-slot": "^1.1.0", 132 | "debug": "^4.3.1", 133 | "denque": "^1.1.0", 134 | "lodash.defaults": "^4.2.0", 135 | "lodash.flatten": "^4.4.0", 136 | "p-map": "^2.1.0", 137 | "redis-commands": "1.7.0", 138 | "redis-errors": "^1.2.0", 139 | "redis-parser": "^3.0.0", 140 | "standard-as-callback": "^2.1.0" 141 | }, 142 | "engines": { 143 | "node": ">=6" 144 | } 145 | }, 146 | "node_modules/lodash.defaults": { 147 | "version": "4.2.0", 148 | "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", 149 | "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" 150 | }, 151 | "node_modules/lodash.flatten": { 152 | "version": "4.4.0", 153 | "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", 154 | "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" 155 | }, 156 | "node_modules/ms": { 157 | "version": "2.1.2", 158 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 159 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 160 | }, 161 | "node_modules/node-fetch": { 162 | "version": "2.6.1", 163 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 164 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", 165 | "engines": { 166 | "node": "4.x || >=6.0.0" 167 | } 168 | }, 169 | "node_modules/object-assign": { 170 | "version": "4.1.1", 171 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 172 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", 173 | "engines": { 174 | "node": ">=0.10.0" 175 | } 176 | }, 177 | "node_modules/p-map": { 178 | "version": "2.1.0", 179 | "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", 180 | "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==", 181 | "engines": { 182 | "node": ">=6" 183 | } 184 | }, 185 | "node_modules/pako": { 186 | "version": "1.0.11", 187 | "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", 188 | "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" 189 | }, 190 | "node_modules/redis-commands": { 191 | "version": "1.7.0", 192 | "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", 193 | "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" 194 | }, 195 | "node_modules/redis-errors": { 196 | "version": "1.2.0", 197 | "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", 198 | "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=", 199 | "engines": { 200 | "node": ">=4" 201 | } 202 | }, 203 | "node_modules/redis-parser": { 204 | "version": "3.0.0", 205 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", 206 | "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", 207 | "dependencies": { 208 | "redis-errors": "^1.0.0" 209 | }, 210 | "engines": { 211 | "node": ">=4" 212 | } 213 | }, 214 | "node_modules/standard-as-callback": { 215 | "version": "2.1.0", 216 | "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", 217 | "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" 218 | }, 219 | "node_modules/util-deprecate": { 220 | "version": "1.0.2", 221 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 222 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 223 | } 224 | }, 225 | "dependencies": { 226 | "@assemblyscript/loader": { 227 | "version": "0.10.1", 228 | "resolved": "https://registry.npmjs.org/@assemblyscript/loader/-/loader-0.10.1.tgz", 229 | "integrity": "sha512-H71nDOOL8Y7kWRLqf6Sums+01Q5msqBW2KhDUTemh1tvY04eSkSXrK0uj/4mmY0Xr16/3zyZmsrxN7CKuRbNRg==" 230 | }, 231 | "abort-controller": { 232 | "version": "3.0.0", 233 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", 234 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", 235 | "requires": { 236 | "event-target-shim": "^5.0.0" 237 | } 238 | }, 239 | "base64-js": { 240 | "version": "1.5.1", 241 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", 242 | "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==" 243 | }, 244 | "btoa-lite": { 245 | "version": "1.0.0", 246 | "resolved": "https://registry.npmjs.org/btoa-lite/-/btoa-lite-1.0.0.tgz", 247 | "integrity": "sha1-M3dm2hWAEhD92VbCLpxokaudAzc=" 248 | }, 249 | "cluster-key-slot": { 250 | "version": "1.1.0", 251 | "resolved": "https://registry.npmjs.org/cluster-key-slot/-/cluster-key-slot-1.1.0.tgz", 252 | "integrity": "sha512-2Nii8p3RwAPiFwsnZvukotvow2rIHM+yQ6ZcBXGHdniadkYGZYiGmkHJIbZPIV9nfv7m/U1IPMVVcAhoWFeklw==" 253 | }, 254 | "cross-fetch": { 255 | "version": "3.1.2", 256 | "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.2.tgz", 257 | "integrity": "sha512-+JhD65rDNqLbGmB3Gzs3HrEKC0aQnD+XA3SY6RjgkF88jV2q5cTc5+CwxlS3sdmLk98gpPt5CF9XRnPdlxZe6w==", 258 | "requires": { 259 | "node-fetch": "2.6.1" 260 | } 261 | }, 262 | "debug": { 263 | "version": "4.3.1", 264 | "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", 265 | "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", 266 | "requires": { 267 | "ms": "2.1.2" 268 | } 269 | }, 270 | "denque": { 271 | "version": "1.5.0", 272 | "resolved": "https://registry.npmjs.org/denque/-/denque-1.5.0.tgz", 273 | "integrity": "sha512-CYiCSgIF1p6EUByQPlGkKnP1M9g0ZV3qMIrqMqZqdwazygIA/YP2vrbcyl1h/WppKJTdl1F85cXIle+394iDAQ==" 274 | }, 275 | "dotenv": { 276 | "version": "8.2.0", 277 | "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-8.2.0.tgz", 278 | "integrity": "sha512-8sJ78ElpbDJBHNeBzUbUVLsqKdccaa/BXF1uPTw3GrvQTBgrQrtObr2mUrE38vzYd8cEv+m/JBfDLioYcfXoaw==" 279 | }, 280 | "event-target-shim": { 281 | "version": "5.0.1", 282 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", 283 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" 284 | }, 285 | "faunadb": { 286 | "version": "4.1.2", 287 | "resolved": "https://registry.npmjs.org/faunadb/-/faunadb-4.1.2.tgz", 288 | "integrity": "sha512-NJn9LBf/63ZD3i9bPAz8uBMvEXmnkfsPHn5AGMD8WBvKfJ4NaQ0AXadTK0NItVHvcZPIIqyc5BlgskveTNB+bA==", 289 | "requires": { 290 | "abort-controller": "^3.0.0", 291 | "base64-js": "^1.2.0", 292 | "btoa-lite": "^1.0.0", 293 | "cross-fetch": "^3.0.6", 294 | "dotenv": "^8.2.0", 295 | "fn-annotate": "^1.1.3", 296 | "object-assign": "^4.1.0", 297 | "util-deprecate": "^1.0.2" 298 | } 299 | }, 300 | "fn-annotate": { 301 | "version": "1.2.0", 302 | "resolved": "https://registry.npmjs.org/fn-annotate/-/fn-annotate-1.2.0.tgz", 303 | "integrity": "sha1-KNoAARfephhC/mHzU/Qc9Mk6en4=" 304 | }, 305 | "hdr-histogram-js": { 306 | "version": "2.0.1", 307 | "resolved": "https://registry.npmjs.org/hdr-histogram-js/-/hdr-histogram-js-2.0.1.tgz", 308 | "integrity": "sha512-uPZxl1dAFnjUFHWLZmt93vUUvtHeaBay9nVNHu38SdOjMSF/4KqJUqa1Seuj08ptU1rEb6AHvB41X8n/zFZ74Q==", 309 | "requires": { 310 | "@assemblyscript/loader": "^0.10.1", 311 | "base64-js": "^1.2.0", 312 | "pako": "^1.0.3" 313 | } 314 | }, 315 | "ioredis": { 316 | "version": "4.24.2", 317 | "resolved": "https://registry.npmjs.org/ioredis/-/ioredis-4.24.2.tgz", 318 | "integrity": "sha512-SSuVXwoG747sZetxxs9gyAno5kfUfvo4s5mSZp4dh8vzuTnrtA5mTf2OjL6sPfIfNbVTROg2c+VbXceGlpucPQ==", 319 | "requires": { 320 | "cluster-key-slot": "^1.1.0", 321 | "debug": "^4.3.1", 322 | "denque": "^1.1.0", 323 | "lodash.defaults": "^4.2.0", 324 | "lodash.flatten": "^4.4.0", 325 | "p-map": "^2.1.0", 326 | "redis-commands": "1.7.0", 327 | "redis-errors": "^1.2.0", 328 | "redis-parser": "^3.0.0", 329 | "standard-as-callback": "^2.1.0" 330 | } 331 | }, 332 | "lodash.defaults": { 333 | "version": "4.2.0", 334 | "resolved": "https://registry.npmjs.org/lodash.defaults/-/lodash.defaults-4.2.0.tgz", 335 | "integrity": "sha1-0JF4cW/+pN3p5ft7N/bwgCJ0WAw=" 336 | }, 337 | "lodash.flatten": { 338 | "version": "4.4.0", 339 | "resolved": "https://registry.npmjs.org/lodash.flatten/-/lodash.flatten-4.4.0.tgz", 340 | "integrity": "sha1-8xwiIlqWMtK7+OSt2+8kCqdlph8=" 341 | }, 342 | "ms": { 343 | "version": "2.1.2", 344 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 345 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 346 | }, 347 | "node-fetch": { 348 | "version": "2.6.1", 349 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 350 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" 351 | }, 352 | "object-assign": { 353 | "version": "4.1.1", 354 | "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", 355 | "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=" 356 | }, 357 | "p-map": { 358 | "version": "2.1.0", 359 | "resolved": "https://registry.npmjs.org/p-map/-/p-map-2.1.0.tgz", 360 | "integrity": "sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==" 361 | }, 362 | "pako": { 363 | "version": "1.0.11", 364 | "resolved": "https://registry.npmjs.org/pako/-/pako-1.0.11.tgz", 365 | "integrity": "sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw==" 366 | }, 367 | "redis-commands": { 368 | "version": "1.7.0", 369 | "resolved": "https://registry.npmjs.org/redis-commands/-/redis-commands-1.7.0.tgz", 370 | "integrity": "sha512-nJWqw3bTFy21hX/CPKHth6sfhZbdiHP6bTawSgQBlKOVRG7EZkfHbbHwQJnrE4vsQf0CMNE+3gJ4Fmm16vdVlQ==" 371 | }, 372 | "redis-errors": { 373 | "version": "1.2.0", 374 | "resolved": "https://registry.npmjs.org/redis-errors/-/redis-errors-1.2.0.tgz", 375 | "integrity": "sha1-62LSrbFeTq9GEMBK/hUpOEJQq60=" 376 | }, 377 | "redis-parser": { 378 | "version": "3.0.0", 379 | "resolved": "https://registry.npmjs.org/redis-parser/-/redis-parser-3.0.0.tgz", 380 | "integrity": "sha1-tm2CjNyv5rS4pCin3vTGvKwxyLQ=", 381 | "requires": { 382 | "redis-errors": "^1.0.0" 383 | } 384 | }, 385 | "standard-as-callback": { 386 | "version": "2.1.0", 387 | "resolved": "https://registry.npmjs.org/standard-as-callback/-/standard-as-callback-2.1.0.tgz", 388 | "integrity": "sha512-qoRRSyROncaz1z0mvYqIE4lCd9p2R90i6GxW3uZv5ucSu8tU7B5HXUP1gG8pVZsYNVaXjk8ClXHPttLyxAL48A==" 389 | }, 390 | "util-deprecate": { 391 | "version": "1.0.2", 392 | "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", 393 | "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" 394 | } 395 | } 396 | } 397 | -------------------------------------------------------------------------------- /newsapis/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "newsapis", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "handler.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "author": "", 10 | "license": "ISC", 11 | "dependencies": { 12 | "faunadb": "^4.1.2", 13 | "hdr-histogram-js": "^2.0.1", 14 | "ioredis": "^4.24.2", 15 | "mongodb": "^4.0.1", 16 | "node-fetch": "^2.6.1" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /newsapis/redisHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Redis = require("ioredis"); 4 | const { performance } = require("perf_hooks"); 5 | const client = new Redis(process.env.REDIS_URL); 6 | module.exports.load = async (event) => { 7 | let section = process.env.SECTION; 8 | let start = performance.now(); 9 | let data = await client.zrevrange(section, 0, 9) 10 | let items = [] 11 | for(let i = 0; i < data.length; i++) { 12 | items.push(JSON.parse(data[i])); 13 | } 14 | // response is ready so we can set the latency 15 | let latency = performance.now() - start; 16 | // we are setting random scores to top-10 items to simulate real time dynamic data 17 | for(let i = 0; i < data.length; i++) { 18 | let view_count = Math.floor(Math.random() * 1000); 19 | await client.zadd(section, view_count, data[i]); 20 | } 21 | // await client.quit(); 22 | // pushing the latency to the histogram 23 | const client2 = new Redis(process.env.LATENCY_REDIS_URL); 24 | await client2.lpush("histogram-redis", latency) 25 | await client2.quit(); 26 | return { 27 | statusCode: 200, 28 | headers: { 29 | 'Access-Control-Allow-Origin': '*', 30 | 'Access-Control-Allow-Credentials': true, 31 | }, 32 | body: JSON.stringify( { 33 | latency: latency, 34 | data: { 35 | Items: items 36 | }, 37 | }) 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /newsapis/redisMultizoneHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Redis = require("ioredis"); 4 | const { performance } = require("perf_hooks"); 5 | const client = new Redis(process.env.REDIS_MZ_URL); 6 | module.exports.load = async (event) => { 7 | let section = process.env.SECTION; 8 | let start = performance.now(); 9 | let data = await client.zrevrange(section, 0, 9) 10 | let items = [] 11 | for(let i = 0; i < data.length; i++) { 12 | items.push(JSON.parse(data[i])); 13 | } 14 | // response is ready so we can set the latency 15 | let latency = performance.now() - start; 16 | // we are setting random scores to top-10 items to simulate real time dynamic data 17 | for(let i = 0; i < data.length; i++) { 18 | let view_count = Math.floor(Math.random() * 1000); 19 | await client.zadd(section, view_count, data[i]); 20 | } 21 | // await client.quit(); 22 | // pushing the latency to the histogram 23 | const client2 = new Redis(process.env.LATENCY_REDIS_URL); 24 | await client2.lpush("histogram-redismz", latency) 25 | await client2.quit(); 26 | return { 27 | statusCode: 200, 28 | headers: { 29 | 'Access-Control-Allow-Origin': '*', 30 | 'Access-Control-Allow-Credentials': true, 31 | }, 32 | body: JSON.stringify( { 33 | latency: latency, 34 | data: { 35 | Items: items 36 | }, 37 | }) 38 | }; 39 | }; 40 | -------------------------------------------------------------------------------- /newsapis/redisRestHandler.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Redis = require("ioredis"); 4 | const fetch = require("node-fetch"); 5 | const { performance } = require("perf_hooks"); 6 | const client = new Redis(process.env.REDIS_REST_URL); 7 | module.exports.load = async (event) => { 8 | let section = process.env.SECTION; 9 | let start = performance.now(); 10 | let url = process.env.REDIS_REST_ENDPOINT +"zrevrange/"+section+"/0/9\?_token\=" + process.env.REDIS_REST_TOKEN; 11 | let data = await fetch(url) 12 | let dd = (await data.json()).result 13 | let items = [] 14 | for(let i = 0; i < dd.length; i++) { 15 | items.push(JSON.parse(dd[i])); 16 | } 17 | // response is ready so we can set the latency 18 | let latency = performance.now() - start; 19 | // we are setting random scores to top-10 items to simulate real time dynamic data 20 | for(let i = 0; i < dd.length; i++) { 21 | let view_count = Math.floor(Math.random() * 1000); 22 | await client.zadd(section, view_count, dd[i]); 23 | } 24 | // pushing the latency to the histogram 25 | const client2 = new Redis(process.env.LATENCY_REDIS_URL); 26 | await client2.lpush("histogram-redisrest", latency) 27 | await client2.quit(); 28 | 29 | return { 30 | statusCode: 200, 31 | headers: { 32 | 'Access-Control-Allow-Origin': '*', 33 | 'Access-Control-Allow-Credentials': true, 34 | }, 35 | body: JSON.stringify( { 36 | latency: latency, 37 | data: { 38 | Items: items 39 | }, 40 | }) 41 | }; 42 | }; 43 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | 2 | Check [the live application](https://serverless-battleground.vercel.app/) and [the blogpost](https://blog.upstash.com/serverless-database-benchmark). 3 | --------------------------------------------------------------------------------