{"id":396196,"date":"2024-06-29T12:41:43","date_gmt":"2024-06-29T12:41:43","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=396196"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=396196","title":{"rendered":"<span>Using a headless browser for WebRTC load tests<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ce\/4be\/efb\/1ce4beefb81204dcd0de7fe67c7cebfa.png\" width=\"1024\" height=\"578\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ce\/4be\/efb\/1ce4beefb81204dcd0de7fe67c7cebfa.png\"\/><figcaption><\/figcaption><\/figure>\n<p>In the previous article we went over a load test whose data could be used to choose a load-appropriate server.  In the course of the testing, we would publish a stream on one <a href=\"https:\/\/flashphoner.com\/review-of-wcs-5-2-server-for-webcast-and-webcam-developers\/\">WCS<\/a>, and we would pick up that stream several times using a second WCS. The acquired results could be used as a basis for decisions on server operability. <\/p>\n<p>Some would (justly) have concerns regarding the possible biases in such a test \u2014 after all, one of our servers was used to test another one of our servers. Could it be that we were using a specially optimized code that skewed the results in our favor? <\/p>\n<p>It is true that the end user will not use a second server to watch streams. The end user will watch them in browser.  This is why, seemingly the simplest and most logical way would involve manual testing: open a browser, open a tab with the <a href=\"https:\/\/flashphoner.com\/player-for-browser\/\">player<\/a>, specify the stream name and click &#171;Play;&#187; and then repeat 1000 times. All that&#8217;s left is to find <s>a guinea pig<\/s> a volunteer tester and a PC that could handle 1000 tabs with video. Alternatively, and more realistically, the same test could involve a group of people and multiple PCs. Or we could just use scripts.<\/p>\n<p>In this article we are going to discuss another testing method, one that uses a headless browser. We will compare the test results with the results from the <a href=\"https:\/\/flashphoner.com\/what-kind-of-server-do-you-need-to-run-a-thousand-webrtc-streams\/\">stream capture-based testing<\/a>.  <\/p>\n<h3>You can&#8217;t leave your head on<\/h3>\n<p>\u041deadless-browser is something without a head. In the context of the frontend, it is an indispensable developer tool with which you can test code, check the quality and consistency of the layout, programmatically create scenarios of user interaction with the site, followed by fixing the results of these scenarios for use in tests. <\/p>\n<p>Headless Chrome) is a full-featured browser without a graphical interface, which means it draws everything in memory. Headless Chrome is faster and uses less memory than a regular browser.  <\/p>\n<p>The last statement seems like a contradiction. But the reduction in memory usage is achieved by the absence of a graphical component. The headless browser has no real content rendering, which means that it does not need to render illustrations weighing several gigabytes, with which modern websites are often flooded. At the same time, the headless browser will download all the content from the web page, just like a regular browser.<\/p>\n<p>Headless Chrome is software-driven using an API and can be installed on &#171;pure&#187; Linux. You just need to install the package, and the browser will work out of the box, just like its brother with a head \u2013 Google Chrome.<\/p>\n<p>Load testing using Headless Chrome will be closest to reality because it simulates real users connecting to WCS using a browser.<\/p>\n<p>So here we go.<\/p>\n<h3>WebRTC load test in a headless browser<\/h3>\n<h4>Server under test<\/h4>\n<p>We will install on the server with the following characteristics<\/p>\n<ul>\n<li>\n<p>2x Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz (a total of 24 cores, 48 streams);<\/p>\n<\/li>\n<li>\n<p>192GB RAM;<\/p>\n<\/li>\n<li>\n<p>2x 10Gbps<\/p>\n<\/li>\n<\/ul>\n<p>a WCS and perform work to prepare for operation in production. Read more in the <a href=\"https:\/\/flashphoner.com\/what-kind-of-server-do-you-need-to-run-a-thousand-webrtc-streams\/\">article<\/a> and in <a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Quick+deployment+and+testing+of+the+server\">documentation<\/a>.  <\/p>\n<p>In the standard Two-way Streaming example, we published the stream from the virtual camera titled &#171;stream1&#187;. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b58\/933\/17b\/b5893317b3fb4b078e57ff8937b92ed2.png\" width=\"841\" height=\"573\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b58\/933\/17b\/b5893317b3fb4b078e57ff8937b92ed2.png\"\/><figcaption><\/figcaption><\/figure>\n<p>That&#8217;s all. Now leave the server to wait for the load test. <\/p>\n<h4>Testing server<\/h4>\n<p>A server with Ubuntu 20.04 OS was used in testing <\/p>\n<p>Characteristics: <\/p>\n<ul>\n<li>\n<p>2x Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz (a total of 24 cores, 48 streams);<\/p>\n<\/li>\n<li>\n<p>192GB RAM;<\/p>\n<\/li>\n<li>\n<p>2x 10Gbps<\/p>\n<\/li>\n<\/ul>\n<p>Setup and testing process: <\/p>\n<p>1. Install Xvfb, Xorg for working with a virtual output device:<\/p>\n<pre><code class=\"bash\">apt-get install xvfb -y apt-get install x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xserver-xorg-core xserver-xorg-video-dummy alsa-base -y<\/code><\/pre>\n<p>2. Configure the virtual monitor \u2013 edit the configuration file \/usr\/share\/X11\/xorg.conf.d\/xorg.conf:<\/p>\n<pre><code class=\"bash\">Section \"Device\"     Identifier  \"Configured Video Device\"     Driver      \"dummy\"     Option \"ConstantDPI\" \"true\"     VideoRam 192000 EndSection   Section \"Monitor\"     Identifier  \"Configured Monitor\"     HorizSync 31.5-48.5     VertRefresh 50-70     Modeline \"1600x1200\" 22.04 1600 1632 1712 1744 1200 1229 1231 1261     Modeline \"1600x900\" 33.92 1600 1632 1760 1792 900 921 924 946     Modeline \"1440x900\" 30.66 1440 1472 1584 1616 900 921 924 946     ModeLine \"1366x768\" 72.00 1366 1414 1446 1494  768 771 777 803     Modeline \"1280x1024\" 31.50 1280 1312 1424 1456 1024 1048 1052 1076     Modeline \"1280x800\" 24.15 1280 1312 1400 1432 800 819 822 841     Modeline \"1280x768\" 23.11 1280 1312 1392 1424 768 786 789 807     Modeline \"1360x768\" 24.49 1360 1392 1480 1512 768 786 789 807     Modeline \"1024x768\" 18.71 1024 1056 1120 1152 768 786 789 807     Modeline \"768x1024\" 19.50 768 800 872 904 1024 1048 1052 1076 EndSection   Section \"Screen\"     Identifier  \"Default Screen\"     Monitor     \"Configured Monitor\"     Device      \"Configured Video Device\"     DefaultDepth 24     SubSection \"Display\"         Depth 24         Modes \"1600x1200\" \"1680x1050\" \"1600x900\" \"1400x1050\" \"1440x900\" \"1280x1024\" \"1366x768\" \"1280x800\" \"1024x768\"     EndSubSection EndSection<\/code><\/pre>\n<p>3. Install Headless Chrome<\/p>\n<pre><code class=\"bash\">wget -q -O - https:\/\/dl-ssl.google.com\/linux\/linux_signing_key.pub | sudo apt-key add - echo \"deb [arch=amd64] http:\/\/dl.google.com\/linux\/chrome\/deb\/ stable main\" > \/etc\/apt\/sources.list.d\/google-chrome.list apt-get update apt-get install google-chrome-stable<\/code><\/pre>\n<p>4. Download and unpack the load testing scripts. An archive with load testing scripts is available for downloading <a href=\"https:\/\/flashphoner.com\/downloads\/docs\/2017\/xload.tar.gz\">here<\/a>.<\/p>\n<pre><code class=\"bash\">wget https:\/\/flashphoner.com\/downloads\/docs\/2017\/xload.tar.gz tar -xvzf xload.tar.gz<\/code><\/pre>\n<p>5. Go to the directory in which the archive was extracted<\/p>\n<pre><code class=\"bash\">cd xload<\/code><\/pre>\n<p>The directory contains:<\/p>\n<ul>\n<li>\n<p><strong>player<\/strong> with Web-player scripts <\/p>\n<\/li>\n<li>\n<p><strong>start_xorg.sh<\/strong> &#8212; script for running Xorg <\/p>\n<\/li>\n<li>\n<p><strong>loadtest.sh<\/strong> &#8212; script for running tests<\/p>\n<\/li>\n<\/ul>\n<p>The following parameters can be passed to the loadtest.sh script:<\/p>\n<p>required:<\/p>\n<ul>\n<li>\n<p>\u200b<strong>url<\/strong> &#8212; URL of the player page with the necessary parameters \u200b<\/p>\n<p>or <\/p>\n<\/li>\n<li>\n<p>\u200b<strong>urlsfile<\/strong> &#8212; the path to the file containing several such URLs, which will be traversed in order<\/p>\n<\/li>\n<\/ul>\n<p>optional:<\/p>\n<ul>\n<li>\n<p><strong>stressrate<\/strong> &#8212; interval of adding a new subscriber in milliseconds;<\/p>\n<\/li>\n<li>\n<p><strong>ttl<\/strong> &#8212; subscriber lifetime in seconds;<\/p>\n<\/li>\n<li>\n<p><strong>maxsubscribers<\/strong> &#8212; maximum number of subscribers.<\/p>\n<\/li>\n<\/ul>\n<p>6. Run testing<\/p>\n<pre><code class=\"bash\">.\/loadtest.sh -url http:\/\/Your.WCS.server:8081\/client2\/examples\/demo\/streaming\/player\/player.html?streamName=stream1&amp;autoplay=true -maxsubscribers 100 -stressrate 500 -ttl 600<\/code><\/pre>\n<p>The screenshot below shows the test result:  <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/943\/9aa\/df2\/9439aadf22362a03d4d324e073e8750c.png\" width=\"1920\" height=\"970\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/943\/9aa\/df2\/9439aadf22362a03d4d324e073e8750c.png\"\/><figcaption><\/figcaption><\/figure>\n<p>Unfortunately, because of the heavy load on the testing server it was not possible to connect to the test 1000 subscribers. Chrome, although headless, but took up all available CPU and RAM resources, with only 50 subscribers, as you can see in the CPU Load Averrage and memory consumption graphs. A long-lasting CPU Load Averrage value of more than 100 points indicates a high load on the processor. The RAM of the testing server also turned out to be occupied by more than 50%.  And if the RAM resource was still available, the CPU load did not allow to reach the planned number of spectators. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b63\/f23\/4bd\/b63f234bdccd7a24765dcbcdcf3ed42d.png\" width=\"1855\" height=\"305\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b63\/f23\/4bd\/b63f234bdccd7a24765dcbcdcf3ed42d.png\"\/><figcaption><\/figcaption><\/figure>\n<p>In this test it was possible to connect a little more than 50 subscribers. In this case, there is no heavy load on the WCS server. <\/p>\n<p>CPU Load Averrage value does not exceed 1 point. Pauses in the operation of Z Garbage Collector did not exceed 3.5 milliseconds. There were no degraded streams. <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/43a\/88a\/eaf\/43a88aeafb00c5c396b80ce219d2ead9.png\" width=\"1856\" height=\"620\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/43a\/88a\/eaf\/43a88aeafb00c5c396b80ce219d2ead9.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>WebRTC load test &#171;from WCS to WCS&#187;<\/h3>\n<p>The testing methodology is discussed in detail in the <a href=\"https:\/\/flashphoner.com\/what-kind-of-server-do-you-need-to-run-a-thousand-webrtc-streams\/\">article<\/a> and in <a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Quick+deployment+and+testing+of+the+server\">documentation<\/a><\/p>\n<p>We will use two servers with the following specifications to test using stream capture:<\/p>\n<ul>\n<li>\n<p>2x Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz (a total of 24 cores, 48 streams);<\/p>\n<\/li>\n<li>\n<p>192GB RAM;<\/p>\n<\/li>\n<li>\n<p>2x 10Gbps<\/p>\n<\/li>\n<\/ul>\n<p>Let&#8217;s launch <a href=\"https:\/\/docs.flashphoner.com\/pages\/viewpage.action?pageId=9242540\">load testing<\/a> using the Console web app:<\/p>\n<p>1. On the first server, open the Console app via HTTP <a href=\"http:\/\/your.WCS.server.name:9091\/client2\/examples\/demo\/streaming\/console\/console.html\">http:\/\/your.WCS.server.name:9091\/client2\/examples\/demo\/streaming\/console\/console.html<\/a><\/p>\n<p>2. Specify the domain name or IP address of the first server and click &#171;Add node.&#187; This will be the server under test, which will be the source of streams. Then similarly connect the second server, which will simulate subscribers and capture streams.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cdd\/23a\/1a0\/cdd23a1a088794e52ab73caa7d2468d1.png\" width=\"954\" height=\"226\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cdd\/23a\/1a0\/cdd23a1a088794e52ab73caa7d2468d1.png\"\/><figcaption><\/figcaption><\/figure>\n<p>3. For the first server, run the standard Two-way Streaming example and publish the stream from the web camera. The stream name can be anything.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/28c\/8ad\/2d5\/28c8ad2d59a7cf35ce7967f6310ce5bc.png\" width=\"954\" height=\"618\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/28c\/8ad\/2d5\/28c8ad2d59a7cf35ce7967f6310ce5bc.png\"\/><figcaption><\/figcaption><\/figure>\n<p>4. In the Console app, select the second server, click &#8216;Pull streams&#8217; button, and set the test parameters:<\/p>\n<ul>\n<li>\n<p><strong>Choose node<\/strong> \u2014 choose the first server;<\/p>\n<\/li>\n<li>\n<p><strong>Local stream name<\/strong> \u2014 specify the name of the stream on the testing server in which the stream from the one being tested will be captured. (index corresponding to the number of the captured stream will be added to the stream name)<\/p>\n<\/li>\n<li>\n<p><strong>Remote stream name<\/strong> \u2014 specify the name of the stream published on the server under test;<\/p>\n<\/li>\n<li>\n<p><strong>Qty<\/strong> \u2014 specify the number of spectators (for our test \u2014 1000).<\/p>\n<\/li>\n<\/ul>\n<p>5. Then press the &#171;Pull&#187; button to start the test: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/197\/706\/476\/197706476ec10c3b3e9cc15df7003742.png\" width=\"954\" height=\"521\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/197\/706\/476\/197706476ec10c3b3e9cc15df7003742.png\"\/><figcaption><\/figcaption><\/figure>\n<p>The test result is on the screenshot below: <\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/85f\/fd1\/8b3\/85ffd18b32a908a4d5dc5d8f8d0d9352.png\" width=\"969\" height=\"545\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/85f\/fd1\/8b3\/85ffd18b32a908a4d5dc5d8f8d0d9352.png\"\/><figcaption><\/figcaption><\/figure>\n<p>When testing using stream capturing, we managed to reach the planned number of viewers (1000 subscribers). The graphs show the increased load on the WCS server being tested. <\/p>\n<p>The test using the second WCS server cannot be considered completely independent. We test our server using the second server of the same type. And, as it was already mentioned above, this variant is very rare in practice. <\/p>\n<p>Despite the fact that we were not able to reach the estimated load of 1000 viewers when testing with Headless Chrome, this test clearly shows that with a small number of real subscribers there is no need to use powerful hardware to host WCS, and you can save some money when buying or renting a server. <\/p>\n<p>Happy streaming! <\/p>\n<details class=\"spoiler\">\n<summary>Links<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/demo.flashphoner.com\/admin\/login.html\">Demo<\/a><\/p>\n<p><a href=\"https:\/\/flashphoner.com\/amazon-ec2-support-in-web-call-server\">WCS on Amazon EC2<\/a><\/p>\n<p><a href=\"https:\/\/flashphoner.com\/web-call-server-on-digital-ocean-marketplace\">WCS on DigitalOcean<\/a><\/p>\n<p><a href=\"https:\/\/flashphoner.com\/support-web-call-server-in-docker\">WCS in Docker<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Load+testing+using+another+server\">Load testing using Headless Chrome<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Settings+file+flashphoner.properties\">Settings file flashphoner.properties<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Settings+file+wcs-core.properties\">Settings file wcs-core.properties<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Server+tuning+recommendations\">Server tuning recommendations<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Memory+management+in+Java\">Memory management in Java<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Before+moving+to+production\">Before moving to production<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/pages\/viewpage.action?pageId=9242540\">Load testing using WebRTC\/RTMP pulling<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Quick+deployment+and+testing+of+the+server\">Quick deployment and testing of the server<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Load+and+resource+usage+information\">Load and resource usage information<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Connecting+from+Prometheus\">Monitoring with Prometheus<\/a><\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/570250\/\"> https:\/\/habr.com\/ru\/articles\/570250\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>In the previous article we went over a load test whose data could be used to choose a load-appropriate server.  In the course of the testing, we would publish a stream on one <a href=\"https:\/\/flashphoner.com\/review-of-wcs-5-2-server-for-webcast-and-webcam-developers\/\">WCS<\/a>, and we would pick up that stream several times using a second WCS. The acquired results could be used as a basis for decisions on server operability. <\/p>\n<p>Some would (justly) have concerns regarding the possible biases in such a test \u2014 after all, one of our servers was used to test another one of our servers. Could it be that we were using a specially optimized code that skewed the results in our favor? <\/p>\n<p>It is true that the end user will not use a second server to watch streams. The end user will watch them in browser.  This is why, seemingly the simplest and most logical way would involve manual testing: open a browser, open a tab with the <a href=\"https:\/\/flashphoner.com\/player-for-browser\/\">player<\/a>, specify the stream name and click &#171;Play;&#187; and then repeat 1000 times. All that&#8217;s left is to find <s>a guinea pig<\/s> a volunteer tester and a PC that could handle 1000 tabs with video. Alternatively, and more realistically, the same test could involve a group of people and multiple PCs. Or we could just use scripts.<\/p>\n<p>In this article we are going to discuss another testing method, one that uses a headless browser. We will compare the test results with the results from the <a href=\"https:\/\/flashphoner.com\/what-kind-of-server-do-you-need-to-run-a-thousand-webrtc-streams\/\">stream capture-based testing<\/a>.  <\/p>\n<h3>You can&#8217;t leave your head on<\/h3>\n<p>\u041deadless-browser is something without a head. In the context of the frontend, it is an indispensable developer tool with which you can test code, check the quality and consistency of the layout, programmatically create scenarios of user interaction with the site, followed by fixing the results of these scenarios for use in tests. <\/p>\n<p>Headless Chrome) is a full-featured browser without a graphical interface, which means it draws everything in memory. Headless Chrome is faster and uses less memory than a regular browser.  <\/p>\n<p>The last statement seems like a contradiction. But the reduction in memory usage is achieved by the absence of a graphical component. The headless browser has no real content rendering, which means that it does not need to render illustrations weighing several gigabytes, with which modern websites are often flooded. At the same time, the headless browser will download all the content from the web page, just like a regular browser.<\/p>\n<p>Headless Chrome is software-driven using an API and can be installed on &#171;pure&#187; Linux. You just need to install the package, and the browser will work out of the box, just like its brother with a head \u2013 Google Chrome.<\/p>\n<p>Load testing using Headless Chrome will be closest to reality because it simulates real users connecting to WCS using a browser.<\/p>\n<p>So here we go.<\/p>\n<h3>WebRTC load test in a headless browser<\/h3>\n<h4>Server under test<\/h4>\n<p>We will install on the server with the following characteristics<\/p>\n<ul>\n<li>\n<p>2x Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz (a total of 24 cores, 48 streams);<\/p>\n<\/li>\n<li>\n<p>192GB RAM;<\/p>\n<\/li>\n<li>\n<p>2x 10Gbps<\/p>\n<\/li>\n<\/ul>\n<p>a WCS and perform work to prepare for operation in production. Read more in the <a href=\"https:\/\/flashphoner.com\/what-kind-of-server-do-you-need-to-run-a-thousand-webrtc-streams\/\">article<\/a> and in <a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Quick+deployment+and+testing+of+the+server\">documentation<\/a>.  <\/p>\n<p>In the standard Two-way Streaming example, we published the stream from the virtual camera titled &#171;stream1&#187;. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>That&#8217;s all. Now leave the server to wait for the load test. <\/p>\n<h4>Testing server<\/h4>\n<p>A server with Ubuntu 20.04 OS was used in testing <\/p>\n<p>Characteristics: <\/p>\n<ul>\n<li>\n<p>2x Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz (a total of 24 cores, 48 streams);<\/p>\n<\/li>\n<li>\n<p>192GB RAM;<\/p>\n<\/li>\n<li>\n<p>2x 10Gbps<\/p>\n<\/li>\n<\/ul>\n<p>Setup and testing process: <\/p>\n<p>1. Install Xvfb, Xorg for working with a virtual output device:<\/p>\n<pre><code class=\"bash\">apt-get install xvfb -y apt-get install x11-xkb-utils xfonts-100dpi xfonts-75dpi xfonts-scalable xfonts-cyrillic xserver-xorg-core xserver-xorg-video-dummy alsa-base -y<\/code><\/pre>\n<p>2. Configure the virtual monitor \u2013 edit the configuration file \/usr\/share\/X11\/xorg.conf.d\/xorg.conf:<\/p>\n<pre><code class=\"bash\">Section \"Device\"     Identifier  \"Configured Video Device\"     Driver      \"dummy\"     Option \"ConstantDPI\" \"true\"     VideoRam 192000 EndSection   Section \"Monitor\"     Identifier  \"Configured Monitor\"     HorizSync 31.5-48.5     VertRefresh 50-70     Modeline \"1600x1200\" 22.04 1600 1632 1712 1744 1200 1229 1231 1261     Modeline \"1600x900\" 33.92 1600 1632 1760 1792 900 921 924 946     Modeline \"1440x900\" 30.66 1440 1472 1584 1616 900 921 924 946     ModeLine \"1366x768\" 72.00 1366 1414 1446 1494  768 771 777 803     Modeline \"1280x1024\" 31.50 1280 1312 1424 1456 1024 1048 1052 1076     Modeline \"1280x800\" 24.15 1280 1312 1400 1432 800 819 822 841     Modeline \"1280x768\" 23.11 1280 1312 1392 1424 768 786 789 807     Modeline \"1360x768\" 24.49 1360 1392 1480 1512 768 786 789 807     Modeline \"1024x768\" 18.71 1024 1056 1120 1152 768 786 789 807     Modeline \"768x1024\" 19.50 768 800 872 904 1024 1048 1052 1076 EndSection   Section \"Screen\"     Identifier  \"Default Screen\"     Monitor     \"Configured Monitor\"     Device      \"Configured Video Device\"     DefaultDepth 24     SubSection \"Display\"         Depth 24         Modes \"1600x1200\" \"1680x1050\" \"1600x900\" \"1400x1050\" \"1440x900\" \"1280x1024\" \"1366x768\" \"1280x800\" \"1024x768\"     EndSubSection EndSection<\/code><\/pre>\n<p>3. Install Headless Chrome<\/p>\n<pre><code class=\"bash\">wget -q -O - https:\/\/dl-ssl.google.com\/linux\/linux_signing_key.pub | sudo apt-key add - echo \"deb [arch=amd64] http:\/\/dl.google.com\/linux\/chrome\/deb\/ stable main\" > \/etc\/apt\/sources.list.d\/google-chrome.list apt-get update apt-get install google-chrome-stable<\/code><\/pre>\n<p>4. Download and unpack the load testing scripts. An archive with load testing scripts is available for downloading <a href=\"https:\/\/flashphoner.com\/downloads\/docs\/2017\/xload.tar.gz\">here<\/a>.<\/p>\n<pre><code class=\"bash\">wget https:\/\/flashphoner.com\/downloads\/docs\/2017\/xload.tar.gz tar -xvzf xload.tar.gz<\/code><\/pre>\n<p>5. Go to the directory in which the archive was extracted<\/p>\n<pre><code class=\"bash\">cd xload<\/code><\/pre>\n<p>The directory contains:<\/p>\n<ul>\n<li>\n<p><strong>player<\/strong> with Web-player scripts <\/p>\n<\/li>\n<li>\n<p><strong>start_xorg.sh<\/strong> &#8212; script for running Xorg <\/p>\n<\/li>\n<li>\n<p><strong>loadtest.sh<\/strong> &#8212; script for running tests<\/p>\n<\/li>\n<\/ul>\n<p>The following parameters can be passed to the loadtest.sh script:<\/p>\n<p>required:<\/p>\n<ul>\n<li>\n<p>\u200b<strong>url<\/strong> &#8212; URL of the player page with the necessary parameters \u200b<\/p>\n<p>or <\/p>\n<\/li>\n<li>\n<p>\u200b<strong>urlsfile<\/strong> &#8212; the path to the file containing several such URLs, which will be traversed in order<\/p>\n<\/li>\n<\/ul>\n<p>optional:<\/p>\n<ul>\n<li>\n<p><strong>stressrate<\/strong> &#8212; interval of adding a new subscriber in milliseconds;<\/p>\n<\/li>\n<li>\n<p><strong>ttl<\/strong> &#8212; subscriber lifetime in seconds;<\/p>\n<\/li>\n<li>\n<p><strong>maxsubscribers<\/strong> &#8212; maximum number of subscribers.<\/p>\n<\/li>\n<\/ul>\n<p>6. Run testing<\/p>\n<pre><code class=\"bash\">.\/loadtest.sh -url http:\/\/Your.WCS.server:8081\/client2\/examples\/demo\/streaming\/player\/player.html?streamName=stream1&amp;autoplay=true -maxsubscribers 100 -stressrate 500 -ttl 600<\/code><\/pre>\n<p>The screenshot below shows the test result:  <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>Unfortunately, because of the heavy load on the testing server it was not possible to connect to the test 1000 subscribers. Chrome, although headless, but took up all available CPU and RAM resources, with only 50 subscribers, as you can see in the CPU Load Averrage and memory consumption graphs. A long-lasting CPU Load Averrage value of more than 100 points indicates a high load on the processor. The RAM of the testing server also turned out to be occupied by more than 50%.  And if the RAM resource was still available, the CPU load did not allow to reach the planned number of spectators. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>In this test it was possible to connect a little more than 50 subscribers. In this case, there is no heavy load on the WCS server. <\/p>\n<p>CPU Load Averrage value does not exceed 1 point. Pauses in the operation of Z Garbage Collector did not exceed 3.5 milliseconds. There were no degraded streams. <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>WebRTC load test &#171;from WCS to WCS&#187;<\/h3>\n<p>The testing methodology is discussed in detail in the <a href=\"https:\/\/flashphoner.com\/what-kind-of-server-do-you-need-to-run-a-thousand-webrtc-streams\/\">article<\/a> and in <a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Quick+deployment+and+testing+of+the+server\">documentation<\/a><\/p>\n<p>We will use two servers with the following specifications to test using stream capture:<\/p>\n<ul>\n<li>\n<p>2x Intel(R) Xeon(R) Silver 4214 CPU @ 2.20GHz (a total of 24 cores, 48 streams);<\/p>\n<\/li>\n<li>\n<p>192GB RAM;<\/p>\n<\/li>\n<li>\n<p>2x 10Gbps<\/p>\n<\/li>\n<\/ul>\n<p>Let&#8217;s launch <a href=\"https:\/\/docs.flashphoner.com\/pages\/viewpage.action?pageId=9242540\">load testing<\/a> using the Console web app:<\/p>\n<p>1. On the first server, open the Console app via HTTP <a href=\"http:\/\/your.WCS.server.name:9091\/client2\/examples\/demo\/streaming\/console\/console.html\">http:\/\/your.WCS.server.name:9091\/client2\/examples\/demo\/streaming\/console\/console.html<\/a><\/p>\n<p>2. Specify the domain name or IP address of the first server and click &#171;Add node.&#187; This will be the server under test, which will be the source of streams. Then similarly connect the second server, which will simulate subscribers and capture streams.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>3. For the first server, run the standard Two-way Streaming example and publish the stream from the web camera. The stream name can be anything.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>4. In the Console app, select the second server, click &#8216;Pull streams&#8217; button, and set the test parameters:<\/p>\n<ul>\n<li>\n<p><strong>Choose node<\/strong> \u2014 choose the first server;<\/p>\n<\/li>\n<li>\n<p><strong>Local stream name<\/strong> \u2014 specify the name of the stream on the testing server in which the stream from the one being tested will be captured. (index corresponding to the number of the captured stream will be added to the stream name)<\/p>\n<\/li>\n<li>\n<p><strong>Remote stream name<\/strong> \u2014 specify the name of the stream published on the server under test;<\/p>\n<\/li>\n<li>\n<p><strong>Qty<\/strong> \u2014 specify the number of spectators (for our test \u2014 1000).<\/p>\n<\/li>\n<\/ul>\n<p>5. Then press the &#171;Pull&#187; button to start the test: <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>The test result is on the screenshot below: <\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>When testing using stream capturing, we managed to reach the planned number of viewers (1000 subscribers). The graphs show the increased load on the WCS server being tested. <\/p>\n<p>The test using the second WCS server cannot be considered completely independent. We test our server using the second server of the same type. And, as it was already mentioned above, this variant is very rare in practice. <\/p>\n<p>Despite the fact that we were not able to reach the estimated load of 1000 viewers when testing with Headless Chrome, this test clearly shows that with a small number of real subscribers there is no need to use powerful hardware to host WCS, and you can save some money when buying or renting a server. <\/p>\n<p>Happy streaming! <\/p>\n<details class=\"spoiler\">\n<summary>Links<\/summary>\n<div class=\"spoiler__content\">\n<p><a href=\"https:\/\/demo.flashphoner.com\/admin\/login.html\">Demo<\/a><\/p>\n<p><a href=\"https:\/\/flashphoner.com\/amazon-ec2-support-in-web-call-server\">WCS on Amazon EC2<\/a><\/p>\n<p><a href=\"https:\/\/flashphoner.com\/web-call-server-on-digital-ocean-marketplace\">WCS on DigitalOcean<\/a><\/p>\n<p><a href=\"https:\/\/flashphoner.com\/support-web-call-server-in-docker\">WCS in Docker<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Load+testing+using+another+server\">Load testing using Headless Chrome<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Settings+file+flashphoner.properties\">Settings file flashphoner.properties<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Settings+file+wcs-core.properties\">Settings file wcs-core.properties<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Server+tuning+recommendations\">Server tuning recommendations<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Memory+management+in+Java\">Memory management in Java<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Before+moving+to+production\">Before moving to production<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/pages\/viewpage.action?pageId=9242540\">Load testing using WebRTC\/RTMP pulling<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Quick+deployment+and+testing+of+the+server\">Quick deployment and testing of the server<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Load+and+resource+usage+information\">Load and resource usage information<\/a><\/p>\n<p><a href=\"https:\/\/docs.flashphoner.com\/display\/WCS52EN\/Connecting+from+Prometheus\">Monitoring with Prometheus<\/a><\/p>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/570250\/\"> https:\/\/habr.com\/ru\/articles\/570250\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-396196","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/396196","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=396196"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/396196\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=396196"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=396196"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=396196"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}