diff --git a/README.md b/README.md index 580c16f..82291d0 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,20 @@ These examples demonstrate how to use [faast.js](https://github.com/faastjs/faast.js) in different ways. -| example | description | language | -| ------------------------------- | ----------------------------------------------------- | ---------- | -| [aws-command][] | run a command on AWS | TypeScript | -| [aws-cost-analyzer-js][] | cost analyzer example | JavaScript | -| [aws-cost-analyzer-ts][] | cost analyzer example | TypeScript | -| [aws-js][] | aws example showing common feaures | JavaScript | -| [aws-lodash-ts][] | example using lodash as a bundled dependency | TypeScript | -| [aws-puppeteer-ts][] | example using puppeteer as a native dependency | TypeScript | -| [aws-sharp-ts][] | example using sharp as a native dependency | TypeScript | -| [aws-ts][] | aws example showing common features | TypeScript | -| [babel][] | babel example | JavaScript | -| [cost-analyzer-comparison-ts][] | compare AWS Lambda and Google Cloud Functions pricing | TypeScript | -| [gcp-ts][] | google cloud example showing common features | TypeScript | -| [gcp-js][] | google cloud example showing common features | JavaScript | -| [hello-world-js][] | hello world | JavaScript | -| [hello-world-ts][] | hello world | TypeScript | +| example | description | language | +| ------------------------------- | ---------------------------------------------- | ---------- | +| [aws-command][] | run a command on AWS | TypeScript | +| [aws-cost-analyzer-js][] | cost analyzer example | JavaScript | +| [aws-cost-analyzer-ts][] | cost analyzer example | TypeScript | +| [aws-js][] | aws example showing common feaures | JavaScript | +| [aws-lodash-ts][] | example using lodash as a bundled dependency | TypeScript | +| [aws-puppeteer-ts][] | example using puppeteer as a native dependency | TypeScript | +| [aws-sharp-ts][] | example using sharp as a native dependency | TypeScript | +| [aws-ts][] | aws example showing common features | TypeScript | +| [babel][] | babel example | JavaScript | +| [cost-analyzer-comparison-ts][] | compare AWS Lambda pricing | TypeScript | +| [hello-world-js][] | hello world | JavaScript | +| [hello-world-ts][] | hello world | TypeScript | [aws-command]: ./aws-command [aws-cost-analyzer-js]: ./aws-cost-analyzer-js @@ -29,8 +27,6 @@ These examples demonstrate how to use [faast.js](https://github.com/faastjs/faas [aws-ts]: ./aws-ts [babel]: ./babel [cost-analyzer-comparison-ts]: ./cost-analyzer-comparison-ts -[gcp-ts]: ./gcp-ts -[gcp-js]: ./gcp-js [hello-world-js]: ./hello-world-js [hello-world-ts]: ./hello-world-ts diff --git a/cost-analyzer-comparison-ts/README.md b/cost-analyzer-comparison-ts/README.md index f7c54e3..8a0bdff 100644 --- a/cost-analyzer-comparison-ts/README.md +++ b/cost-analyzer-comparison-ts/README.md @@ -1,6 +1,6 @@ -# faast.js Cost Analyzer example comparing AWS Lambda and Google Cloud Functions costs +# faast.js Cost Analyzer example comparing AWS Lambda costs -The cost analyzer summarizes the cost of running a particular workload against multiple configurations. In this example, we generate 100,000 random numbers in each workload. For each memory size, the workload is executed 10 times. Then the workload is executed on both AWS Lambda and Google Cloud Functions, with memory sizes that include 128MB, 256MB, 512MB, 1024MB, 2048MB. In addition, AWS is tested with 1728MB. The results are printed in real time to the console and also output in CSV format to the file "cost.csv". +The cost analyzer summarizes the cost of running a particular workload against multiple configurations. In this example, we generate 100,000 random numbers in each workload. For each memory size, the workload is executed 10 times. Then the workload is executed on AWS Lambda with memory sizes that include 128MB, 256MB, 512MB, 1024MB, 2048MB. In addition, AWS is tested with 1728MB. The results are printed in real time to the console and also output in CSV format to the file "cost.csv". ## Prerequisites @@ -8,8 +8,6 @@ The cost analyzer summarizes the cost of running a particular workload against m - AWS account and IAM user. See faast.js documentation for account setup instructions. -- Google Cloud account. See faast.js documentation for account setup instructions. - ## Installing dependencies ```shell diff --git a/cost-analyzer-comparison-ts/index.ts b/cost-analyzer-comparison-ts/index.ts index f158e92..5851b2f 100644 --- a/cost-analyzer-comparison-ts/index.ts +++ b/cost-analyzer-comparison-ts/index.ts @@ -15,9 +15,6 @@ const configurations = [ ...CostAnalyzer.awsConfigurations.filter(c => memorySizes.find(m => m === c.options.memorySize!) ) - // ...CostAnalyzer.googleConfigurations.filter(c => - // memorySizes.find(m => m === c.options.memorySize!) - // ) ]; async function compareCloudCosts() { diff --git a/gcp-js/README.md b/gcp-js/README.md deleted file mode 100644 index 3d627eb..0000000 --- a/gcp-js/README.md +++ /dev/null @@ -1,44 +0,0 @@ -# faast.js Google Cloud JavaScript example - -This example demonstrates some typical Google Cloud options in faast.js in JavaScript. - -## Prerequisites - -- Node 8+. - -## Installing dependencies - -```shell -$ npm install -``` - -## Running - -```shell -$ node index.js -``` - -## Expected output - -```text -## Logs -https://console.cloud.google.com/logs/viewer?project=derivative-184723&resource=cloud_function%2Ffunction_name%2Ffaast-bbc6b8e2-79d0-4599-b916-7580c27bcbf2 -## Output -hello GCP! -## Cost -functionCallDuration $0.00001600/second 0.1 second $0.00000160 77.3% [1] -functionCallRequests $0.00000040/request 1 request $0.00000040 19.3% [2] -outboundDataTransfer $0.12000000/GB 0.00000057 GB $0.00000007 3.3% [3] -pubsub $0.05859375/GB 0 GB $0 0.0% [4] ---------------------------------------------------------------------------------------- - $0.00000207 (USD) - - * Estimated using highest pricing tier for each service. Limitations apply. - ** Does not account for free tier. -[1]: https://cloud.google.com/functions/pricing#compute_time (1024 MB, 1.4 GHz) -[2]: https://cloud.google.com/functions/pricing#invocations -[3]: https://cloud.google.com/functions/pricing#networking -[4]: https://cloud.google.com/pubsub/pricing -## Stats -completed: 1, retries: 0, errors: 0, executionTime.mean: 3ms -``` diff --git a/gcp-js/functions.js b/gcp-js/functions.js deleted file mode 100644 index 09ec41e..0000000 --- a/gcp-js/functions.js +++ /dev/null @@ -1,3 +0,0 @@ -exports.hello = function(name) { - return "hello " + name + "!"; -}; diff --git a/gcp-js/index.js b/gcp-js/index.js deleted file mode 100644 index 3b2df9d..0000000 --- a/gcp-js/index.js +++ /dev/null @@ -1,26 +0,0 @@ -const { faastGoogle } = require("faastjs"); -const funcs = require("./functions"); - -async function main() { - const m = await faastGoogle(funcs, { - memorySize: 1024, - timeout: 60, - region: "us-central1" - }); - console.log(`## Logs`); - console.log(`${m.logUrl()}`); - try { - const result = await m.functions.hello("GCP"); - console.log(`## Output`); - console.log(result); - console.log(`## Cost`); - const cost = await m.costSnapshot(); - console.log(`${cost}`); - console.log(`## Stats`); - console.log(`${m.stats()}`); - } finally { - await m.cleanup(); - } -} - -main(); diff --git a/gcp-js/package.json b/gcp-js/package.json deleted file mode 100644 index ff45d05..0000000 --- a/gcp-js/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "faastjs-example-gcp-js", - "main": "index.js", - "license": "Apache-2.0", - "scripts": { - "test": "node index.js" - }, - "dependencies": { - "faastjs": "latest" - } -} diff --git a/gcp-ts/README.md b/gcp-ts/README.md deleted file mode 100644 index b407f7a..0000000 --- a/gcp-ts/README.md +++ /dev/null @@ -1,50 +0,0 @@ -# faast.js Google Cloud TypeScript example - -This example demonstrates some typical Google Cloud options in faast.js in TypeScript. - -## Prerequisites - -- Node 8+. - -## Installing dependencies - -```shell -$ npm install -``` - -## Building - -```shell -$ npm run build -``` - -## Running - -```shell -$ node dist/index.js -``` - -## Expected output - -```text -## Logs -https://console.cloud.google.com/logs/viewer?project=derivative-184723&resource=cloud_function%2Ffunction_name%2Ffaast-664f50a3-c255-4dbe-bbab-a0f9b2bb1762 -## Output -hello GCP! -## Cost -functionCallDuration $0.00001600/second 0.1 second $0.00000160 77.3% [1] -functionCallRequests $0.00000040/request 1 request $0.00000040 19.3% [2] -outboundDataTransfer $0.12000000/GB 0.00000057 GB $0.00000007 3.3% [3] -pubsub $0.05859375/GB 0 GB $0 0.0% [4] ---------------------------------------------------------------------------------------- - $0.00000207 (USD) - - * Estimated using highest pricing tier for each service. Limitations apply. - ** Does not account for free tier. -[1]: https://cloud.google.com/functions/pricing#compute_time (1024 MB, 1.4 GHz) -[2]: https://cloud.google.com/functions/pricing#invocations -[3]: https://cloud.google.com/functions/pricing#networking -[4]: https://cloud.google.com/pubsub/pricing -## Stats -completed: 1, retries: 0, errors: 0, executionTime.mean: 3ms -``` diff --git a/gcp-ts/functions.ts b/gcp-ts/functions.ts deleted file mode 100644 index 353f12a..0000000 --- a/gcp-ts/functions.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function hello(name: string) { - return "hello " + name + "!"; -} diff --git a/gcp-ts/index.ts b/gcp-ts/index.ts deleted file mode 100644 index 10fc6a2..0000000 --- a/gcp-ts/index.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { faastGoogle } from "faastjs"; -import * as funcs from "./functions"; - -async function main() { - const m = await faastGoogle(funcs, { - memorySize: 1024, - timeout: 60, - region: "us-central1" - }); - console.log(`## Logs`); - console.log(`${m.logUrl()}`); - try { - const result = await m.functions.hello("GCP"); - console.log(`## Output`); - console.log(result); - console.log(`## Cost`); - const cost = await m.costSnapshot(); - console.log(`${cost}`); - console.log(`## Stats`); - console.log(`${m.stats()}`); - } finally { - await m.cleanup(); - } -} - -main(); diff --git a/gcp-ts/package.json b/gcp-ts/package.json deleted file mode 100644 index 743576d..0000000 --- a/gcp-ts/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "name": "faastjs-example-gcp-ts", - "main": "index.ts", - "license": "Apache-2.0", - "scripts": { - "build": "tsc", - "watch": "tsc --watch", - "clean": "rm -rf dist", - "test": "node dist/index.js" - }, - "dependencies": { - "faastjs": "latest" - }, - "devDependencies": { - "@types/node": "18.15.3", - "typescript": "^4.9.4" - } -} diff --git a/gcp-ts/tsconfig.json b/gcp-ts/tsconfig.json deleted file mode 100644 index afeca97..0000000 --- a/gcp-ts/tsconfig.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "compilerOptions": { - "outDir": "dist", - "target": "es6", - "lib": ["es6"], - "module": "commonjs", - "moduleResolution": "node", - "sourceMap": true, - "noFallthroughCasesInSwitch": true, - "noImplicitReturns": true, - "forceConsistentCasingInFileNames": true, - "skipLibCheck": true, - "strict": true - }, - "exclude": ["node_modules", "dist"] -}