Coder Social home page Coder Social logo

oatpp / benchmark-websocket Goto Github PK

View Code? Open in Web Editor NEW
95.0 5.0 14.0 81 KB

Websocket Client and Server for benchmarks with Millions of concurrent connections.

Home Page: https://oatpp.io/

License: Apache License 2.0

CMake 6.19% Dockerfile 0.96% C++ 84.93% Shell 7.93%
oatpp websocket benchmark millions-of-connections

benchmark-websocket's Introduction

Stand With Ukraine


Oat++ Logo

 

oatpp build status Join the chat at https://gitter.im/oatpp-framework/Lobby

Oat++

Oat++ is a modern Web Framework for C++. It's fully loaded and contains all necessary components for effective production level development. It's also light and has a small memory footprint.

News

  • ⚠️ Attention! Oat++ main repo is bumping its version to 1.4.0. While 1.4.0 is IN DEVELOPMENT use 1.3.0-latest tag.
  • Follow the changelog for news and features in version 1.4.0.
  • Consider supporting Oat++ via the GitHub sponsors page.

Start

Support the Project

Maintaining and developing this project requires significant time and resources. If you enjoy using it and want to support its continued development, please consider supporting us through GitHub Sponsors.

Become a Sponsor on GitHub

Every contribution, big or small, helps us keep improving and maintaining the project. Thank you for your support!

About

Quick Overview

Shortcuts:

Build Powerful API And Document It With Swagger-UI

See ApiController for more details.

ENDPOINT_INFO(getUserById) {
  info->summary = "Get one User by userId";

  info->addResponse<Object<UserDto>>(Status::CODE_200, "application/json");
  info->addResponse<Object<StatusDto>>(Status::CODE_404, "application/json");
  info->addResponse<Object<StatusDto>>(Status::CODE_500, "application/json");

  info->pathParams["userId"].description = "User Identifier";
}
ENDPOINT("GET", "users/{userId}", getUserById,
         PATH(Int32, userId))
{
  return createDtoResponse(Status::CODE_200, m_userService.getUserById(userId));
}

Access Databases And Keep Your Data Consistent

See Oat++ ORM for more details.

QUERY(createUser,
      "INSERT INTO users (username, email, role) VALUES (:username, :email, :role);",
      PARAM(oatpp::String, username), 
      PARAM(oatpp::String, email), 
      PARAM(oatpp::Enum<UserRoles>::AsString, role))

Join Our Community

Examples

REST-API

  • REST Service - A complete example of a "CRUD" service (UserService) built with Oat++. REST + Swagger-UI + SQLite.
  • REST Client - Example project of how-to use Retrofit-like client wrapper (ApiClient) and how it works.

WebSocket

  • Can Chat - Feature-complete rooms-based chat for tens of thousands users. Client plus Server.
  • WebSocket - Collection of oatpp WebSocket examples.
  • YUV Websocket Stream - Example project how-to create a YUV image stream from a V4L device (i.E. Webcam) using websockets.

Databases

  • SQLite - A complete example of a "CRUD" service. REST + Swagger-UI + SQLite.
  • PostgreSQL - Example of a production-grade entity service storing information in PostgreSQL. With Swagger-UI and configuration profiles.
  • MongoDB - Example project how to work with MongoDB using oatpp-mongo mondule. Project is a web-service with basic CRUD and Swagger-UI.

IoT

  • Example-IoT-Hue - Example project how-to create an Philips Hue compatible REST-API that is discovered and controllable by Hue compatible Smart-Home devices like Amazon Alexa or Google Echo.

Streaming

  • HTTP Live Streaming Server - Example project on how to build an HLS-streaming server using Oat++ asynchronous API.
  • YUV Websocket Stream - Example project how-to create a YUV image stream from a V4L device (i.E. Webcam) using websockets.

TLS

  • TLS With Libressl - Example project how-to setup secure connection and serve via HTTPS.

Microservices

Asynchronous API

  • Async Service - Example project on how to use asynchronous API to handle a large number of simultaneous connections.

Frequently Asked Questions

Q: "Oat++" name?

  • "Oat" is something light, organic, and green. It can be easily cooked and consumed with no effort.
  • "++" gives a hint that it is "something" for C++.

Q: What is the main area of Oat++ application?

Oat++ is used for many different purposes, from building REST APIs that run on embedded devices to building microservices and highly-loaded cloud applications.

But the majority of use cases appears to be in IoT and Robotics.

Q: How portable is Oat++?

Theoretically, Oat++ can be easily ported everywhere where you have threads and network stack. With an additional comparably small effort, it can be ported almost everywhere depending on how much you strip it and what would be the final binary size.

See supported platforms for additional info.

Q: What is the size of a minimal Oat++ application?

About 1Mb, depending on C/C++ std-lib and oatpp version.

Q: Which Oat++ API to choose, Simple or Async?

Always choose Simple API wherever possible. Simple API is more developed and makes the code cleaner.

Async API is designed for small, specific tasks that run at high concurrency levels ex.:

  • Serving file downloads to a large number of concurrent users (1K users and more).
  • Streaming to a large number of clients (1K or more).
  • Websocket Chat servers.

For all other purposes use simple API.

benchmark-websocket's People

Contributors

lganzzzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

benchmark-websocket's Issues

Issue connecting

Hi there,
first of all, thanks for your amazing work on the oatpp. I am not much of a C++ expert but i would like to use the benchmark-websocket client to loadtest a websocket server implementation I already have. The client needs to setup a seperate websocket connection using ws:/// where every client needs to have a random clientid.

Is this possible using the oatpp libraries?

Any hints?

thanks in advance!
Riccardo

benchmark runtime_error

./wsb-client-exe --tp 2 --tio 2 --socks-max
100 --socks-port 100 --si 100 --sf 30 --pc 1 -h 192.168.2.28
D |2021-06-09 21:15:39 1623244539526502| Client:add clients for port 20029
D |2021-06-09 21:15:39 1623244539560469| Client:Waiting clients to connect...
D |2021-06-09 21:15:39 1623244539560649| Status:
SOCKETS: 100
D |2021-06-09 21:15:49 1623244549566251| FRAMES_TOTAL: 25705
D |2021-06-09 21:15:49 1623244549566324| MESSAGES_TOTAL: 25172
D |2021-06-09 21:15:49 1623244549566364| FRAMES_PER_MIN: 154145.374190
D |2021-06-09 21:15:49 1623244549566402| MESSAGES_PER_MIN: 150949.128928
E |2021-06-09 21:15:49 1623244549729510| [oatpp::async::worker::IOEventWorker::setEpollEvent()]:Error. Call to epoll_ctl failed. operation=1, errno=17
terminate called after throwing an instance of 'std::runtime_error'
what(): [oatpp::async::worker::IOEventWorker::setEpollEvent()]: Error. Call to epoll_ctl failed.
Aborted

Build error

$ cd ~/benchmark-websocket/server/main/build
$ make
Scanning dependencies of target my-project-lib
[ 12%] Building CXX object CMakeFiles/my-project-lib.dir/src/Logger.cpp.o
[ 25%] Building CXX object CMakeFiles/my-project-lib.dir/src/controller/WebSocketListener.cpp.o
[ 37%] Linking CXX static library libmy-project-lib.a
[ 37%] Built target my-project-lib
Scanning dependencies of target my-project-test
[ 50%] Building CXX object CMakeFiles/my-project-test.dir/test/tests.cpp.o
/home/ubuntu/benchmark-websocket/server/main/test/tests.cpp: In function ‘int main()’:
/home/ubuntu/benchmark-websocket/server/main/test/tests.cpp:20:51: error: no matching function for call to ‘oatpp::base::Environment::setLogger(Logger*)’
   oatpp::base::Environment::setLogger(new Logger());
                                                   ^
In file included from /home/ubuntu/benchmark-websocket/server/main/src/Logger.hpp:13:0,
                 from /home/ubuntu/benchmark-websocket/server/main/test/tests.cpp:2:
/usr/local/include/oatpp-0.19.4/oatpp/oatpp/core/base/Environment.hpp:299:15: note: candidate: static void oatpp::base::Environment::setLogger(const std::shared_ptr<oatpp::base::Logger>&)
   static void setLogger(const std::shared_ptr<Logger>& logger);
               ^~~~~~~~~
/usr/local/include/oatpp-0.19.4/oatpp/oatpp/core/base/Environment.hpp:299:15: note:   no known conversion for argument 1 from ‘Logger*’ to ‘const std::shared_ptr<oatpp::base::Logger>&’
CMakeFiles/my-project-test.dir/build.make:62: recipe for target 'CMakeFiles/my-project-test.dir/test/tests.cpp.o' failed
make[2]: *** [CMakeFiles/my-project-test.dir/test/tests.cpp.o] Error 1
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/my-project-test.dir/all' failed
make[1]: *** [CMakeFiles/my-project-test.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2

Error. Can't connect.

./wsb-client-exe --tp 16 --tio 8 -h 127.0.0.1 --socks-max 5000000 --socks-port 6001 --si 1000 --sf 30 --pc 500

D |2024-01-19 03:32:59 1705613579555767| Client:add clients for port 8000
D |2024-01-19 03:32:59 1705613579556326| ClientCoroutine:Error. [oatpp::network::tcp::client::ConnectionProvider::getConnectionAsync()]: Error. Can't connect.
E |2024-01-19 03:32:59 1705613579556346| ASSERT[FAILED]:false && "handleError - any error in WebSocket communication is considered to be fatal in this benchmark"

I'm using PHP Ratchet Socket server with SSL (own generated)

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.