Coder Social home page Coder Social logo

cloudflare-worker-speed-test's Introduction

CloudFlare worker speed test


Update: after changes to how cloudflare compiles WebAssembly described here the performance of CloudFlare workers with large wasm modules has improved enormously.

For the largest case below the response time has dropped from 2844ms to 211ms.


See https://community.cloudflare.com/t/cloudflare-workers-very-slow-with-moderate-sized-webassembly-bindings/184668/12

This worker does one very simple thing: it substitutes the variable {{ name }} in a string and returns that string.

By default the template is Hello, {{ name }} and the value of name is world, both template and name can be customised using GET parameters.

The substitution can be done in the the following ways:

  • in javascript using replace
  • in rust use string replace
  • in rust using regex replace_all
  • in rust using tera one_off

Using these means of substitution varies the wasm module from non existent, to small, medium and large.

Performance results

mode wasm size (kb) mean response time (ms) response stdev (ms)
javascript 0 84 8
simple replace, wee_alloc 20 127 26
simple replace, no wee_alloc 25 133 30
regex, wee_alloc, default-features off 193 540 235
regex, wee_alloc 619 1228 188
tera, wee_alloc, default-features off 1160 2744 452
tera, wee_alloc 2546 2844 496

results plot

Results are calculated using test_performance.py script above, the worker is modified by switching features in Cargo.toml, for the "javascript" case, mode has to be changed in wrangler.toml and some line commented and uncommented in worker/worker.js.

cloudflare-worker-speed-test's People

Contributors

samuelcolvin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.