Why https is faster than http in my apache server? - apache

Server information:
$ httpd -v
Server version: Apache/2.2.24 (Unix)
Server built: May 8 2013 15:17:37
I create a self-signed SSL Certificate with openssl.
Test Code(Java with selenium webdriver):
long startTime, useTime = 0, t;
int count = 10;
for (int i = 0; i < count; i++) {
ChromeDriver driver = new ChromeDriver(capabilities);
startTime = System.nanoTime();
driver.get("https://*.*.*.*/pic.html");
//When testing Http,it will be:driver.get("http://*.*.*.*/pic.html");
//pic.html is a simple page with many images.
t = System.nanoTime() - startTime;
useTime += t;
driver.quit();
}
System.out.println("Average Time: " + useTime/1000000.0/count +" ms");
Result:
HTTPs:Average Time: 1718.13659 ms
HTTP:Average Time: 2484.122677 ms
Thanks in advance.

It might be that using https also enables transparent compression of the content. The time added for compression and encryption (and back of course) might be less than the time saved by transferring less content over a slow link.
You can verify this by:
Using incompressible content (e.g. a large JPEG image)
Speeding up the transfer link significantly (e.g. by using "localhost")

Because Apache and chrome (I see you're using chromedriver) both support http2.0 which is faster for reasons other than encryption but only works with encryption.

Related

Selenium WebDriver Consumes 19,000 MB of Memory.. Takes 10 min to Launch Firefox

I'm using the following code to launch Selenium WebDriver:
public static WebDriver launchWebDriver(String ipAddress, String port)
{
System.setProperty("webdriver.gecko.driver", "PATH_TO_GECKO_DRIVER");
String firefoxInstallationFolder = "PATH_TO_FIREFOX_INSTALLATION_FOLDER";
File firefoxProfileFile = new File(firefoxInstallationFolder);
FirefoxProfile firefoxProfile = new FirefoxProfile(firefoxProfileFile);
firefoxProfile.setPreference("datareporting.policy.dataSubmissionPolicyAccepted", false);
firefoxProfile.setPreference("dom.max_chrome_script_run_time", 0);
firefoxProfile.setPreference("dom.max_script_run_time", 0);
firefoxProfile.setPreference("media.peerconnection.enabled", false);
FirefoxOptions firefoxOptions = new FirefoxOptions();
firefoxOptions.setProfile(firefoxProfile);
firefoxOptions.addPreference("dom.popup_maximum", 200);
firefoxOptions.addPreference("dom.webnotifications.enabled", false);
firefoxOptions.addPreference("media.peerconnection.enabled", false);
firefoxOptions.addPreference("general.useragent.override", "CUSTOM_UA");
DesiredCapabilities dc = DesiredCapabilities.firefox();
if (ipAddress != null && port != null) {
Proxy proxy = new Proxy();
proxy.setHttpProxy(ipAddress + ":" + port);
proxy.setFtpProxy(ipAddress + ":" + port);
proxy.setSslProxy(ipAddress + ":" + port);
dc.setCapability(CapabilityType.PROXY, proxy);
}
firefoxOptions.merge(dc);
WebDriver driver = new FirefoxDriver(firefoxOptions);
return driver;
}
Before running above code Task Manager showed Java Platform Binary consuming 212 MB of memory. After running above code (nothing else was running on my machine at the time) the memory usage starting creeping up to 492 MB then to 636 MB then to 1,946 MB and to 13,000 MB. It hit a high of over 19,000 MB. I'm not running anything other than the default code from Selenium V3.
Below are some screenshots I captured showing how the memory is increasing rapidly.
Note: It started at less than 1,000 MB, but I only started capturing at 12,000 MB but you can see how it zooms from 12,000 MB to over 17,000 MB in screenshots below. Nothing else is running on my PC.
This is true whether or not I pass actual ipAddress and port as argument or whether I pass null for both arguments. The only thing different I can think of is that I've manually set proxy under Options -> General -> Network Settings -> Settings -> Manual Proxy Configuration. I'm obviously running a specific Firefox Profile as well. But I have no idea why this should cause such long launch times and consume so much memory. We're dealing with almost 20 GB of memory!
What's causing such a big memory hog and long launch times?
Thanks
This happens than you reuse Firefox Profile with cached images (may be it is GecoDriver bug I don't know). To fix the problem:
Clean up cache in you Firefox Profile. You can simply delete everything in folder <your_firefox_profile>/cache2
Turn off disk caching in your Firefox browser running under Selenium. May be you can do it with FirefoxOptions but I prefer to set browser.cache.disk.enable to false in about:config

RavenDb extremely slow inserts at around 2KB per seconds

Testing out RavenDb on a standard i7 4790K machine with 24GB Ram and a 512GB NVME SSD.
Using the very basic bulk insert from [RavenDB Bulk Inserts] https://ravendb.net/docs/article-page/4.2/csharp/client-api/bulk-insert/how-to-work-with-bulk-insert-operation , I'm getting extremely slow write speeds with documents being inserted at around 10 per seconds.
using (BulkInsertOperation bulkInsert = store.BulkInsert())
{
for (int i = 0; i < 1000 * 1000; i++)
{
bulkInsert.Store(new Employee
{
FirstName = "FirstName #" + i,
LastName = "LastName #" + i
});
}
}
This seems ridiculously slow and makes me wonder if I'm doing something wrong. The test app is a simple .net core 3.1 console application. I have tried the standard insert as well and the results aren't any different.
The server is running on the same laptop with default install settings and is not setup for a secure connection at the moment.
Any suggestions? Thanks

Paraview looping with SaveScreenshot in a server is very slow

I mean to get a series of snapshots, at a sequence of time steps, of a layout with two views (one RenderView + one LineChartView).
For this I put together a script, see below.
I do
ssh -X myserver
and there I run
~/ParaView-5.4.1-Qt5-OpenGL2-MPI-Linux-64bit/bin/pvbatch myscript.py
The script is extremely slow to run. I conceive the following reasons/bottlenecks:
Communication of the graphic part (ssh -X) from the remote server to my computer.
Display of graphics in my computer.
Processing in the server.
Is there a way to assess which is the bottleneck, with my current resources?
(For instance, I know I could get a faster communication to assess item 1, but I cannot do that now.)
Is there a way to accelerate pvbatch?
The answer likely depends on my system, but perhaps there are generic actions I can take.
Creation of the layout with two views
...
ans = GetAnimationScene()
time_steps = ans.TimeKeeper.TimestepValues
for istep in range(len(time_steps)) :
tstep = time_steps[istep]
ans.AnimationTime = tstep
fname = "combo" + '-' + '{:08d}'.format(istep) + '.png'
print( "Exporting image " + fname + " for time step " + str(tstep) )
SaveScreenshot(fname, viewLayout1, quality=100)
Why do you need the -X ?
Just set DISPLAY to :0 and do not forward graphics.
The bottleneck is most likely the rendering on your local display. If your server has a X server, you can perform the rendering on your server by setting accordingly the DISPLAY environnement variable as Mathieu explained.
If your server does not have a X server running, then the best option is to build Paraview on your server using either the OSMesa backend or the EGL backend (if you have a compatible graphic card on it).

PcapIpAddress returns 0.0.0.0

I am using the following library: Tamir.IPLib.SharpPcap.dll version 1.0.2.0.
Running the Tamir.IPLib.Test.Example1, that is (in very short):
PcapDeviceList devices = SharpPcap.GetAllDevices();
if(devices.Count<1)
{
Console.WriteLine("No device found on this machine");
}
foreach(PcapDevice dev in devices)
{
Console.WriteLine("PcapDescription : " + dev.PcapDescription);
Console.WriteLine("PcapName : " + dev.PcapName);
Console.WriteLine("PcapIpAddress : " + dev.PcapIpAddress);
i++;
}
On a Windows XP version 2002,I am able to obtain the description, name and IP address of my device without any problem.But if using Windows 7 Professional 64 bit SP1, i can obtain only the PcapDescription and PcapName correctly.PcapIpAddress returns instead 0.0.0.0.Why? and What can i do to get the correct IPAddress?
Thanks
I would recommend using the latest release of SharpPcap instead. It has significant improvements, is a continuation of the project Tamir started (has 3+ years of development improvements) and the examples are updated. I'm the author of SharpPcap btw.

NTP Request Packet

I'm trying to figure out what I need to send (client) in the NTP request package to retrieve a NTP package from the server. I'm working with the LWIP on Cortex M3, Stellaris LM3S6965
I understand that I will recieve a UDP header and then the NTP protocol with the different timestamps the remove the latency. I probable need to make an UDP header but what do I need to add as data?
wireshark image:
I hope you guys can help me.
The client request packet is the same as the server reply packet - just set the MODE bits in the first word to 3 (Client) to be sure.
Send the whole 48 byte packet to the server, it will reply with the same.
The simplest packet would be 0x1B followed by 47 zeroes. (Version = 3, mode = 3)
This is for starters: http://www.eecis.udel.edu/~mills/ntp/html/warp.html
Check this out in case you haven't yet: https://www.rfc-editor.org/rfc/rfc5905
Then look at this: http://wiki.wireshark.org/NTP and check out the sample pcap files that they have uploaded.
I am not sure if this helped, but I hope so.
I have coded an Arduino to connect to an NTP server using this code here,
http://www.instructables.com/id/Arduino-Internet-Time-Client/step2/Code/
Look at the method called getTimeAndDate, and sendNTPpacket.
That is the packet that is sent. This is setting up a buffer and shows binary (0b) and hex (0x) being set up in the 48 character buffer. The address is the NTP time server,
memset(packetBuffer, 0, NTP_PACKET_SIZE);
packetBuffer[0] = 0b11100011;
packetBuffer[1] = 0;
packetBuffer[2] = 6;
packetBuffer[3] = 0xEC;
packetBuffer[12] = 49;
packetBuffer[13] = 0x4E;
packetBuffer[14] = 49;
packetBuffer[15] = 52;
Udp.beginPacket(address, 123);
Udp.write(packetBuffer,NTP_PACKET_SIZE);
Udp.endPacket();
Here is what happens to the received packet,
Udp.read(packetBuffer,NTP_PACKET_SIZE); // read the packet into the buffer
unsigned long highWord, lowWord, epoch;
highWord = word(packetBuffer[40], packetBuffer[41]);
lowWord = word(packetBuffer[42], packetBuffer[43]);
epoch = highWord << 16 | lowWord;
epoch = epoch - 2208988800 + timeZoneOffset;
flag=1;
setTime(epoch);
setTime is part of the arduino time library, so the epoch should be the number of seconds since Jan 1, 1900 as suggested here (search for epoch),
https://en.wikipedia.org/wiki/Network_Time_Protocol
But in case you want a C# version, I found this here, compiled the code under the excepted answer and it works. This will likely make more sense to you, and does show the use of epoch 1/1/1900.
How to Query an NTP Server using C#?
Can easily see the similarity.