O'Reilly logo

Mastering Dart by Sergey Akopkokhyants

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Isolates

Now, it's time to discuss the performance of our server. We use an HTTP benchmarking tool such as wrk (https://github.com/wg/wrk) by Will Glozer to help us in our investigation. To avoid confusion, we will take the simplest version of our server, as follows:

import 'dart:io';

main() {
  HttpServer
  .bind(InternetAddress.ANY_IP_V4, 8080)
  .then((server) {
    server.listen((HttpRequest request) {
      // Response back to client
      request.response.write('Hello, world!');
      request.response.close();
    });
  });
}

We use this code with a benchmarking tool and keep the 512 concurrent connections open for 30 seconds, as shown in the following code:

./wrk -t1 –c256 -d30s http://127.0.0.1:8080

Here is the result of the preceding code:

Running 30s test @ http://127.0.0.1:8080 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required