Skip to content

Instantly share code, notes, and snippets.

@jkschneider
Created October 28, 2019 14:46
Show Gist options
  • Save jkschneider/def8ecbd5c5c652246ebff26dfc7e53e to your computer and use it in GitHub Desktop.
Save jkschneider/def8ecbd5c5c652246ebff26dfc7e53e to your computer and use it in GitHub Desktop.
WebClient client = WebClient.builder()
.baseUrl("http://" + args[0])
.build();
Flux
.generate(AtomicLong::new, (state, sink) -> {
long i = state.getAndIncrement();
sink.next(i);
return state;
})
.limitRate(1)
.flatMap(n -> client.get().uri("/MYENDPOINT").exchange())
.doOnNext(resp -> {
if (resp.statusCode().is2xxSuccessful())
counter.increment();
})
.blockLast();
@tircis
Copy link

tircis commented Oct 29, 2019

Hi, you may be interested in https://gatling.io/ instead of JMeter for a more complete product than a simple main program

@slandelle
Copy link

Disclaimer: Gatling author here

Hi,

  • indeed, Gatling uses a non blocking architecture, not a one-thread-per-virtual-user one + blocking IO.
  • what you're doing is only realistic wrt server to server traffic where you share one global connection pool and SSLContext. If you want to simulate web traffic realistically, each virtual user must have its own connections and SSLSessions.

Regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment