Monday, December 16, 2013
handle close event of browser in flash
<script><![CDATA[function(){function callback' + ExternalInterface.objectID+' (){ var fobj = get' + ExternalInterface.objectID + '("' + ExternalInterface.objectID + '"); fobj.callbeforeunload();}function get' + ExternalInterface.objectID + '(movieName) { if (window.document[movieName]) {return window.document[movieName];}if (navigator.appName.indexOf("Microsoft Internet") == -1) {if (document.embeds && document.embeds[movieName])return document.embeds[movieName];}else {return document.getElementById(movieName);}} window.addEventListener?window.addEventListener("beforeunload", callback' + ExternalInterface.objectID+', true):window.attachEvent && window.attachEvent("onbeforeunload" , callback' + ExternalInterface.objectID + ');}]]></script>
Tuning the network
Meticulous configuration of Nginx and Node.js would be futile without first understanding and optimising the transport mechanism over which traffic data is sent. Most commonly, NginX will be connected to your web clients and your upstream applications via TCP sockets.
Your system imposes a variety of thresholds and limits on TCP traffic, dictated by its kernel parameter configuration. The default settings are designed for accommodating generic networking use. They are not necessarily geared up for high-volumes of short-lived connections handled by a web server.
The parameters listed here are the main candidates for tuning TCP throughput of a server. To have these take effect, you can drop them in your
/etc/sysctl.conf
file, or a new config file such as /etc/sysctl.d/99-tuning.conf
and run sysctl -p
to have the kernel pick them up. We use a syctl-cookbook to do the hard work.
Please note the following values are guidelines, and you should be able to use them safely, but you are encouraged to research what each one means so you can choose a value appropriate for your workload, hardware and use-case.
net.ipv4.ip_local_port_range='1024 65000'
net.ipv4.tcp_tw_reuse='1'
net.ipv4.tcp_fin_timeout='15'
net.core.netdev_max_backlog='4096'
net.core.rmem_max='16777216'
net.core.somaxconn='4096'
net.core.wmem_max='16777216'
net.ipv4.tcp_max_syn_backlog='20480'
net.ipv4.tcp_max_tw_buckets='400000'
net.ipv4.tcp_no_metrics_save='1'
net.ipv4.tcp_rmem='4096 87380 16777216'
net.ipv4.tcp_syn_retries='2'
net.ipv4.tcp_synack_retries='2'
net.ipv4.tcp_wmem='4096 65536 16777216'
vm.min_free_kbytes='65536'
Higlighting a few of the important ones…
net.ipv4.ip_local_port_range
To serve a client request via an upstream application, NginX must open 2 TCP connections; one for the client, one for the connection to the upstream. If the server receives many connections, this can rapidly saturate the system’s available port capacity. The net.ipv4.ip_local_port_range directive increases the range to much larger than the default, so we have room for more allocated ports. If you’re seeing errors in your /var/log/syslog such as: “
possible SYN flooding on port 80. Sending cookies
” it might mean the system can’t find an available port for the pending connection. Increasing the capacity will help alleviate this symptom.net.ipv4.tcp_tw_reuse
When the server has to cycle through a high volume of TCP connections, it can build up a large number of connections in TIME_WAIT state. TIME_WAIT means a connection is closed but the allocated resources are yet to be released. Setting this directive to 1 will tell the kernel to try to recycle the allocation for a new connection when safe to do so. This is cheaper than setting up a new connection from scratch.
net.ipv4.tcp_fin_timeout
The minimum number of seconds that must elapse before a connection in TIME_WAIT state can be recycled. Lowering this value will mean allocations will be recycled faster.
How to check connection status
Using netstat:
netstat -tan | awk '{print $6}' | sort | uniq -c
Using ss:
ss -s
How to fix the "LANGUAGE = (unset)" perl errors on Debian
First try two commands:
$export LC_ALL=C.UTF-8
$sudo update-locale
If it does not work try:
Add two lines into /etc/environment file
$vi /etc/enviroment
LANG=en_US.UTF-8
LC_ALL=en_US.UTF-8
If it does not work try:
THE PROBLEM: Perl gives LANGUAGE = unset errors.
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "en_US.UTF-8"
are supported and installed on your system.
perl: warning: Falling back to the standard locale ("C").
locale: Cannot set LC_CTYPE to default locale: No such file
INTERACTIVELY FIX (debian):
# dpkg-reconfigure locales
(Select your language and hit "OK")
PROGRAMTICALLY FIX (debian):
# sed -i "s/^# en_US/en_US/" /etc/locale.gen
# grep -v "^#" /etc/locale.gen
en_US ISO-8859-1
en_US.ISO-8859-15 ISO-8859-15
en_US.UTF-8 UTF-8
#localedef -v -c -i en_US -f UTF-8 en_US.UTF-8
# /usr/sbin/locale-gen
Generating locales (this might take a while)...
en_US.ISO-8859-1... done
en_US.ISO-8859-15... done
en_US.UTF-8... done
Generation complete.
# update-locale LANG=en_US.UTF-8
===========================================================================
Answering myself:
I've managed to solve the problem by adding
Code:
LANGUAGE = en_US.UTF-8 LC_ALL = en_US.UTF-8 LANG = en_US.UTF-8 LC_TYPE=en_US.UTF-8
If it does not work try:
add following to /etc/default/locate
LC_CTYPE=en_US.UTF-8
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
run sudo dpkg-reconfigure locales
select locate en_US.UTF-8 in the "Locates to be generated" tab.
select en_US.UTF-8 in the "Default locate for the system environment" tab.
run sudo reboot
VC++ Error Link 2019: unresolved external symbol "__declspec(dllimport) public: static char* __edecl ..."
Set Properties->C/C++->Language->Treat wchar_t As Built-in Type = No(/Zc:wchar_t-)
Subscribe to:
Posts (Atom)