w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Why doesn't Nginx load balancing balance bandwidth?
It sounds like the configuration is doing exactly what you asked it to do. You configured a proxy on the first server IP, right? So data has to go from the user to the proxy, then to the server, then the reply from the server back to the proxy and then to the user. It's triple because the first server sees three flows (both servers' output from the proxy and the second server's input to the proxy) while the second server sees one (its output to the proxy). It is perfectly balancing the traffic into equal flows, the first server just sees three flows and the second just one. As for how you fix it, it depends what's wrong with it and what you're trying to accomplish, which you haven't told us.

Categories : Nginx

Amazon web service load balancer unable to balance the load equally
There could be a number of reasons for this. Its without doing more digging, its hard to know which one you are experiencing. Sticky sessions can result in instances traffic becoming unbalanced. Although this depends heavily on usage patterns and your application. Cached DNS resolution. Part of how the ELB works is to direct traffic round robin on a DNS level. If a large number of users are all using the same DNS system provided by an ISP, they might all get sent to the same zone. Couple this with sticky sessions and you will end up with a bunch of traffic that will never switch. Using Route 53 with ALIAS records may reduce this somewhat. If you can't get the ELB to balance your traffic better, you can set up something similar with vanish cache or other software load balancer. Not as c

Categories : Amazon

Adding rails apps to nginx avoiding high load time on 1st access
Unicorn sounds like it might be a better fit for your deployment scenario. You can keep nginx up front, but instead of loading rails itself, it will just connect to a unicorn Unix socket. Further, you can reload your application with new code gracefully, while nginx stays up and Unicorn swaps out backend quietly.

Categories : Ruby On Rails

How to create a light-weight server like nginx from scratch?
First off: Create a simple HTTP server with Java? Try this for a simple python server: http://www.linuxjournal.com/content/tech-tip-really-simple-http-server-python Here's a pretty simple java web server: http://cs.au.dk/~amoeller/WWW/javaweb/server.html

Categories : Nginx

Load Balance wso2 ESB
You can add following parameter to http and https transport receivers of WSO2 ESB . <parameter name="WSDLEPRPrefix" locked="false">[load-balancer-url]</parameter> For example: <parameter name="WSDLEPRPrefix" locked="false">http://esb.cloud-test.wso2.com:8280</parameter> You need to edit following file. <WSO2-ESB-HOME>repository/conf/axis2/axis2.xml This step is necessary for configuring WSO2 ELB also. See following ELB doc for more information. http://docs.wso2.org/wiki/pages/viewpage.action?pageId=26839403

Categories : Wso2

Load Balance: Node.js - Socket.io - Redis
Redis only syncs from the master to the slaves. It never syncs from the slaves to the master. So, if you're writing to all 3 of your machines, then the only messages that will wind up synced across all three servers will be the ones hitting the master. This is why it looks like you're missing messages. More info here. Read only slave Since Redis 2.6 slaves support a read-only mode that is enabled by default. This behavior is controlled by the slave-read-only option in the redis.conf file, and can be enabled and disabled at runtime using CONFIG SET. Read only slaves will reject all the write commands, so that it is not possible to write to a slave because of a mistake. This does not mean that the feature is conceived to expose a slave instance to the internet or

Categories : Node Js

Azure windows virtual machine load balance
You need both the virtual machines to be under the same cloud service. Only then you get the option to load balance them. There is no way add existing VMs to the same network. there are operations in the Service management API (usable through powershell) to create a new VM. You can use that to create a fresh VM from your existing image and connect it to the same service as your first VM. Then you'llhave the necessary options enabled for load balancing.

Categories : Azure

Azure Traffic Manager Load Balance Options
Traffic manager comes into picture only when your application is deployed across multiple cloud services within same data center or in different data centers. If your application is hosted in a single cloud service (with multiple instances of course) , then the instances are load balanced using Round Robin pattern. This is the default load balancing pattern and comes to you without any extra charge. You can read more about traffic manager here: https://azure.microsoft.com/en-us/documentation/articles/traffic-manager-overview/

Categories : Azure

Does SQL Server Service Broker load balance when External Activator is used?
To utilise the built-in load balancing you would need to deploy the service to more than one sql server instance. I suspect that isn't quite what you are planning, so you will have to come up with a custom method, such as having an internal activated procedure that forwards your arriving messages into one of your four queues that the external activation processes look at.

Categories : Sql Server

how to internally load balance multiple instances of web/worker roles in Azure?
There is no internal load balancer in Windows Azure. The only load balancer is the one that has the public IP Addresses. If you want to load balance only internal addresses (workers) you have to maintain it yourself. Meaning you have to install some kind of a load balancer on Azure VM, which is part of the same VNet. That load balancer may be of your choice (Windows or Linux). And you have to implement a watchdog service for when topology changes - i.e. workers are being recycled, hardware failure, scaling events. I would not recommend this approach unless this is absolutely necessary. Last option is to have a (cached) pool of IP Endpints of all the workers and randomly chose one when you need.

Categories : Asp Net

Solve heat balance equations in discrete time
I would use a finite difference for the derivatives. dT/dt =~ (T(n) - T(n-1))/(dt) Where T(n) is the temperature at time step n and dt is the time between samples. C1*((T1(n) - T1(n-1))/dt)=U12*A1*(T1(n)-T2(n))+U13*A2*(T1(n)-T3(n))+H1(n) C2*((T2(n) - T2(n-1))/dt)=U21*A1*(T1(n)-T2(n))+U23*A2*(T2(n)-T3(n))+H2(n) Now, just solve the system of equations for T1(n) and T2(n). I use sympy for simple, but tedious algebra like this. Then just initialize all your parameters and simulate the equations for N steps like so: function [T1,T2] = simHeatEqns(N) dt = .. U12 = .. . . . % simulate for N steps for n=2:N T1(n) = (A1*A2*T3(n)*U12*U23*dt^2 - A1*A2*T3(n)*U13*U21*dt^2 + A1*C1*T1(n-1)*U21*dt - A1*C2*T2(n-1)*U12*dt + A1*H1n*U21*dt^2 - A1*H2n*U12*dt^2 + A2^2*T3(n)*U13*U23*dt

Categories : Matlab

Remove hash from URL, load the page at hash-less URL, then add hash to URL without reloading the page
Before page loads, check URL and if it has #/, remove it. Not possible. The fragment id is not sent to the server, so you can only access it with client side code and that requires the page to load (or at least to start loading). Load page located at hash-less url Redisplay the url with #/, without reloading the page Use XMLHttpRequest to get the data, DOM to change the document to use it, and the history API to change the URL in the address bar.

Categories : Javascript

Cypher Query - Returning weight of each matching relationship with total weight
Take a look at http://console.neo4j.org/r/voavd2 The data is: START n=node(1) MATCH n-[r1:LIKES]->m RETURN r1,m Your query returns: START n=node(1) MATCH n-[r1:LIKES]->m WITH r1.frequency AS Frequency, Sum(r1.frequency) AS Sum RETURN Frequency, Sum i.e. grouped by frequency, what is the sum of all frequencies for that value. Is that what you were trying to get?

Categories : Neo4j

Opencart (Weight issue total weight show in grams how to convert in kg)
You could use: <?php $weight = number_format($weight / 1000, 2); ?> Change $weight to the actual variable name. You can change the '2' at the end to however many decimal places you want to display also.

Categories : PHP

What event is fired on page load / hash load
try doing: $(document).on('pageinit', '#show_protocol', function(){ //your code here }); instead of $(document).ready(function() { ... }); use $(document).bind('pageinit') Reference:: jQuery Mobile Events

Categories : Jquery

Where is my nginx being configured? Changing nginx.conf still brings me to the 'Welcome to nginx' page
when you rewrited the nginx.conf in the folder of source code of nginx and installed it firstly, it will be copied to /usr/local/nginx/conf/nginx.conf (without specially modification of the configure in the folder of source code). But when you do this secondly, the nginx.conf in the folder of source code will be copied to /usr/local/nginx/conf/nginx.conf.defualt,and it usually don't work unless you use nginx -c /usr/local/nginx/conf/nginx.conf.defualt to assign its configure file evertime. There is a line NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" in your script above,which indicates the configure file clearly. To handle this, I suggest rewrite /usr/local/nginx/conf/nginx.conf (not the one in the folder of source code) instead.

Categories : Nginx

Python logic - how do I code the maximum weight for two roads that have a variety of maximum weight values?
You can do this all in one expression, but let's break it up to make it easier to understand. First, what's the maximum weight that can be transported on route 1? You already know this part: route1 = min(a, b, c) And the same for route 2: route2 = min(d, e) Now, a truck can take either route, so he'll take whichever one allows transporting the most, so: route_best = max(route1, route2) And now you just need to print that out: print(route_best)

Categories : Python

Setting a trace id in nginx load balancer
In our production environment we do have a custom module like this. It can generate a unique trace id and then it will be pushed into http headers which send to the upstream server. The upstream server will check if the certain field is set, it will get the value and write it to access_log, thus, we can trace the request. And I find an 3rd party module just looks the same: nginx-operationid, hope it is helpful.

Categories : Nginx

Can I use Amazon ELB instead of nginx as load balancer for my Node.Js app?
Yes, but there are a few gotcha to keep in mind: If you have a single server, ensure you don't return anything except 200 to the page that ELB uses to check health. We had a 301 from our non-www to www site, and that made ELB not send anything to our server because of it. You'll get the ELB's IP instead of the client's in your logs. There is an ngx_real_ip module, but it takes from config hacking to get it to work.

Categories : Node Js

Make nginx load different locations for PC and mobile devices
The problem is as indicated: the location directive is not allowed inside an if. There are actually only a few things that are safe to do within if directives, examples are rewrite and return. See the documentation for more detailed information. Something the documentation doesn't mention is that under certain conditions set is also safe to use. In your specific case, try something like this: if ($http_user_agent ~* android) { rewrite ^ /mobile/$request_uri last; # internal rewrite } location /mobile { } Note that I haven't verified your regular expression. I am sure you can tweak that according to your needs.

Categories : Nginx

Obtaining the hash of a file using the stream capabilities of crypto module (ie: without hash.update and hash.digest)
From the quoted snippet in the question: [the Hash class] It is a stream that is both readable and writable. The written data is used to compute the hash. Once the writable side of the stream is ended, use the read() method to get the computed hash digest. So what you need to hash some text is: var crypto = require('crypto'); // change to 'md5' if you want an MD5 hash var hash = crypto.createHash('sha1'); // change to 'binary' if you want a binary hash. hash.setEncoding('hex'); // the text that you want to hash hash.write('hello world'); // very important! You cannot read from the stream until you have called end() hash.end(); // and now you get the resulting hash var sha1sum = hash.read(); If you want to get the hash of a file, the best way is create a ReadStream from th

Categories : Node Js

Running nginx infront of a unicorn or gunicorn under Elastic Load Balancer
In a word: yes. Amazon's ELB service is wonderful, but it is solely a load balancer. Running nginx on your own server gives you a locus of control and a place to do rewrites, redirects, compression, header munging, caching, and more. Furthermore it allows you to serve static files in the fastest possible way, rather than using a slot on your more heavyweight appserver.

Categories : Nginx

Rails 3.2 Nginx Unicorn always try to load index.html (403) from public folder
Finally i found the solution myself. Here is what i did: The other location-blocks interfered so it always loaded the public folder. After I deleted this lines : location / { gzip_static on; } location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; } the nginx server connects to unicorn.

Categories : Ruby On Rails

In a file/array, search for hash key, and replace it with the hash value, do this for all hash keys/values
You exhaust your file the first time through your loop using the initial $find and $replace key/value pair. There are two potential solutions: Open the file for reading during each iteration of your while loop (expensive) Move the foreach loop to the outside of the while and iterate the hash each time (less expensive) example: REPLACE: for my $line (@gtfarray) { while(my ($find, $replace) = each %hash) { if($line =~ s/$find/$replace/g) { push @newgtf, $line; next REPLACE; # skip to next iteration } } # if there was no replacement, push the old line push @newgtf, $line }

Categories : Perl

Improve Nginx Server Response Time
I also use Ubuntu 12.04LTS with nginx and ngx_pagespeed You can follow this link to compile nginx with ngx_pagespeed: https://github.com/pagespeed/ngx_pagespeed#how-to-build You can increase your score without requiring to modify your code. If you want to get a perfect PageSpeed score, this article might help you: http://www.appneta.com/blog/bootstrap-pagespeed . https://github.com/danriti/bootstrap-pagespeed

Categories : Nginx

How do i load page with default hash (ID) content?
If what you're trying to do is scroll to a div on pageload, I suggest reading (/applying) this: jQuery: how to scroll to certain anchor/div on page load?

Categories : Jquery

How to load hash in a loop using objects as keys in JavaScript?
Object keys in JavaScript can only be strings. This means that if you pass something that is not a string, it gets converted to a string. Since you're using objects that don't "override" Object.toString, they'll all have the same string representation (it's "[object Object]"), which is why the hash always refers to the last key used. More here: Strange equality issue with Javascript object properties

Categories : Javascript

jQuery: Math.floor function on hash load
I solved this problem by firing the math.Floor function on window load like so: $(window).load(function(){ var $this = $('.grid-break'); $this.css('height','auto'); var newHeight = $this.height(); newHeight = (Math.floor((newHeight+10)/230)+1)*230-10; $this.css('height',newHeight); });

Categories : Jquery

Ruby: Getting Stack level too deep on YAML.load of hash
Remove this: --- !ruby/hash:Options Leaving this: :auto: true :cbz: true :is_set_up: true That line is a serialized instance of the Options class, and having the Options class load an instance of itself in its initializer is a recipe for stack explosions. This should get things working: def update( key, value ) if self.has_key?( key ) self[key] = value File.open( @path, 'w' ) do |f| f.write( to_h.to_yaml ) end else puts 'That key does not exist' end end to_h.to_yaml writes the hash out as YAML. Also, using the block form of File.open ensures the file is closed at the end of the block.

Categories : Ruby

JMeter latency vs load time(sample time)
Latency is a difference between time when request was sent and time when response has started to be received. Response time (= Sample time = Load time = Elapsed time) is a difference between time when request was sent and time when response has been fully received. So Response time always >= latency. The larger file is, the larger difference between response time and latency will be.

Categories : Java

Elapsed Time to initial load take too long time?
Check more closely with proper tools. Check Firebug. Also YSlow provides lots of good tips.

Categories : PHP

Coalesce date time into a string in params hash?
You could change the data being sent before the ajax call like so (...).on("ajax:beforeSend", function(event, xhr, settings) { settings.data += "&interview_date="+formatted_date_string; }); and format that date string using each of those values from above. Update: But it seems like Rails can convert that information for you - Where is the Rails method that converts data from `datetime_select` into a DateTime object?

Categories : Ruby On Rails

how to set a hash data with multi fields and values one time?
redis_write.HMSet(string.Format("u:{0}:info", Request.Cookies["UserID"].Value), new byte[][] { Encoding.Unicode.GetBytes("Name") , Encoding.Unicode.GetBytes("Sex") , Encoding.Unicode.GetBytes("Birth") , Encoding.Unicode.GetBytes("iURL") , Encoding.Unicode.GetBytes("Info") , Encoding.Unicode.GetBytes("RegLocal") }, new byte[][] { Encoding.Unicode.GetBytes(Request["Name"].ToString()), Encoding.Unicode.GetBytes(Request["Sex"].ToString()), Encoding.Unicode.GetBytes(Request

Categories : C#

Reading from .txt file to array one line at a time (Matlab or C). "Insufficient memory" to load the whole file at once using 'A=load()'.
See this answer. If your file is that big, you should not try to load it all at once. You should read it line by line. If this still doesn't work, you should take a look at the csvread function. Edit: Also this link could be quite helpful 2nd Edit: Try the Matfile io

Categories : C

nginx as load balancer server out 404 page based on HTTP response from app server
Simply set the proxy_intercept_errors option to on and create an nginx error page for it. error_page 404 /404.html; proxy_intercept_errors on; To ensure that nginx will serve the static file from it’s document root you also have to specify the following: location /404.html { internal; } I'm assuming here that nginx is configured to talk with your app servers as proxy, because that is the usual way and your question does not mention any of this.

Categories : Nginx

Restarting nginx: nginx: [alert] Unable to start the Phusion Passenger watchdog because its executable
Passenger takes what you set in the file nginx.conf by passenger_ruby, for example: passenger_root /home/dev/.rvm/gems/ruby-1.9.3-p448/gems/passenger-4.0.5; passenger_ruby /home/dev/.rvm/wrappers/ruby-1.9.3-p448/ruby;

Categories : Ruby

Can a server run Nginx for some sites and Apache Nginx Reverse Proxy for others?
server { server_name example.com; location / { # assuming apache is on port 81 for example proxy_pass http://127.0.0.1:81; # to make apache detect the host header proxy_set_header Host $host; } # if you have assets folders, you can let nginx serve them directly, # instead of passing them to apache location /images { # or /css or /js .. etc try_files $uri =404; } } Note: in the case of assets, sometimes some sites serve assets through rewrites, or even handled by the application it self, you can pass it to apache by adding that in the assets location as a fallback like this location /images { try_files $uri @apache; } location @apache { proxy_pass http://127.0.0.1:81; } In apache you create a virtual host <Virtua

Categories : Apache

How to time ListBox load time WPF
You can use a System.Diagnostics.Stopwatch for this. Make sure that you start it before you set the ListBox.ItemsSource property and stop it as you said, in the ListBox.Loaded event: In XAML: <ListBox Name="ListBox" /> In code constructor: public MainWindow() { InitializeComponent(); ListBox.Loaded += new RoutedEventHandler(ListBox_Loaded); Items.AddRange(Enumerable.Range(1, 100000000)); stopwatch = new Stopwatch(); stopwatch.Start(); ListBox.ItemsSource = Items; } Add the handler with a break point after the call to stop the Stopwatch: private void ListBox_Loaded(object sender, RoutedEventArgs e) { stopwatch.Stop(); TimeSpan elapsedTime = stopwatch.Elapsed; } However, unless you have millions of rows of data, or extremely complicated DataTem

Categories : Wpf

How to load a page in Javascript and MD5 hash it to make sure it is the page we are looking for
Using jQuery to download the page and cross-domain-ajax for the cross domain request. function utf8_encode ( string ) { string = (string+'').replace(/ /g, " ").replace(/ /g, " "); var utftext = ""; var start, end; var stringl = 0; start = end = 0; stringl = string.length; for (var n = 0; n < stringl; n++) { var c1 = string.charCodeAt(n); var enc = null; if (c1 < 128) { end++; } else if((c1 > 127) && (c1 < 2048)) { enc = String.fromCharCode((c1 >> 6) | 192) + String.fromCharCode((c1 & 63) | 128); } else { enc = String.fromCharCode((c1 >> 12) | 224) + String.fromCharCode(((c1 >> 6) & 63) | 128) + String.fromCharCode((c1 & 63) | 128);

Categories : Javascript

How to mock a hash with string keys in rspec which comes from a webservice in the new hash notation of ruby
If the hash is a string key, you're not able to use the new notation. Only with symbols. In the case that you'd really like to access using symbols, one option is to import Rails ActiveSupport and use their Indifferent Access functions. It adds another dependency to manage, but can help keep your code cleaner too.

Categories : Ruby



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.