w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
High-load java server
I do not think that Idea 3 would be over engineering, and I'd hit that road. Building @MessageDriven Bean "adapter" that handles incoming socket connections in the onMessage method is easy to develop and from there you're in the well scaling EE world. You your case, you might even want to rely on UDP. See following example: http://www.apprigger.com/2011/06/javaee-udp-resource-adapter-example/ But from my point of view there are other important reasons to go this way. Some pointers: 1.) As you've already mentioned. Building an own Socket Server handling threads and requests is a lot of work, and at the end you might build your own little "application server". 2.) Don't be afraid of using an application server. Of course people tend to call such a platform "overhead". Though when I did

Categories : Java

Java High-load NIO TCP server
Your logic around writing is faulty. You should attempt the write immediately you have data to write. If the write() returns zero it is then time to register for OP_WRITE, retry the write when the channel becomes writable, and deregister for OP_WRITE when the write has succeeded. You're adding a massive amount of latency here. You're adding even more latency by deregistering for OP_READ while you're doing all that.

Categories : Java

nodejs HTTP server can't handle large response on high load
Right now all strings are first converted to Buffer instances. This can put a heavy load on the garbage collector to cleanup after each request. Running your application with --prof and examining the v8.log file with tools/*-tick-processor and you may see that. There is work being done to correct this so strings are written out to memory directly then cleaned up when the request is complete. It has been implemented for file system writes in f5e13ae, but not yet for other cases (much more difficult to implement than it sounds). Also converting strings to Buffers is very costly. Especially for utf8 strings (which are default). Where you can, definitely pre-cache the string as a Buffer and use it. Here is an example script: var http = require('http'); var str = 'a'; for (var i = 0; i <

Categories : Node Js

Scale out SignalR without Redis for a high-messaging traffic Web app
Depending on the kind of traffic you will be using SignalR for, you might be able to use the Redis Soution. The MSDN Documentation states that the only solution where the Redis Server would be a serious issue is for online gaming but for push scenarios or chat applications, you should be fine. Scaleout in SignalR

Categories : Asp Net

How to optimize vlookup for high search count ? (alternatives to VLOOKUP)
I considered the following alternatives: VLOOKUP array-formula MATCH / INDEX VBA (using a dictionary) The compared performance is: VLOOKUP simple formula : ~10 minutes VLOOKUP array-formula : ~10 minutes (1:1 performance index) MATCH / INDEX : ~2 minutes (5:1 performance index) VBA (using a dictionary) : ~6 seconds (100:1 performance index) Using the same reference sheet 1) Lookup sheet: (vlookup array formula version) A B 1 2 key51359 {=VLOOKUP(A2:A10001;sheet1!$A$2:$B$100001;2;FALSE)} 3 key41232 formula in B2 4 key10102 ... extends to ... ... ... 99999 key4153 ... cell B100001 100000 key12818 ... (select whole range, and press 100001 key35032 ... CTRL+SHIFT+ENTER to make it a

Categories : Performance

How to change redis DB that the redis client is from redis pool
for example: //write bool IsNeedChangeDB=true; int WriteDBNumber=3 public static PooledRedisClientManager pool = RedisDao.CreateManager(hostIp, hostIp); using (var redis = pool.GetClient()) { if (redis is RedisClient && IsNeedChangeDB) { if (redis.Db != this.WriteDBNumber) { ((RedisClient)redis).ChangeDb(this.WriteDBNumber); } else { Trace.WriteLine("it is a test" + redis.Host); } } red

Categories : C#

Which of Yesod's Warp and snap-server should I choose for a high-performance application server?
I would highly recommend making the choice between Warp/Yesod and Snap based on which system provides you with the best set of tools for creating your application. Both Warp and Snap are using the same underlying GHC I/O manager, and both are highly optimized. I would be surprised if a well written application for each system, doing anything non-trivial, showed a significance performance gap. Your last paragraph is a bit vague, but I think the basic answer for either Warp or Snap is to just write your code, and the I/O manager will scale as well as possible. If you really find concurrent connections to be the bottleneck, you could consider trying out the prefork technique, using GHC 7.8 (not yet released, but has a much improved I/O manager), or using multiple servers.

Categories : Haskell

SQL server 2012 : SQL query to get list of database for which a server is secondary in high availability configuration
So, I don't have an exact query for you but it shouldn't be too hard to do, there are 2 DMVs to look at for this: sys.dm_hadr_availability_group_states - This will tell you about the availability groups and which servers are primary/secondary replicas for each sys.dm_hadr_database_replica_states - This will tell you about the databases within each availibility group and what state they are in Join the two of these together on the group_id column and you will be able to see what databases are in which availability group and which servers are acting as primary/secondary replicas. Links to the docs here: AlwaysOn Availability Groups Dynamic Management Views and Functions

Categories : Sql Server

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

High CPU load on ORMLite query
The resulting data is about 9kB in total. Is there anything wrong with the code? I don't immediately see any problems with your code. I'd make sure that userId is in an index if you have a large table but I suspect that isn't the issue. @DatabaseField(index = true) private String userId; You might also want to add an index to the foreign UserDTO field in the event table if that table is large but again I don't think the performance problem is on the Sqlite end unless your databases are large. One query optimization that you could try is to use another WHERE constraint when getting the events instead of the join: QueryBuilder<EventViewDTO, Long> eventQb = eventDao.queryBuilder(); // the "userDto" needs to be changed to whatever the foreign field name is data.eventViews =

Categories : Android

scipy.optimize dll load failure on Windows 8
I really encourage you to Install SciPy and NumPy with one these packages: Python(x,y) Anaconda Enthought Other wise you will end up with all the strange error because these packages mainly based on C libraries that they need to be compiled and usually standard Windows installation doesn't have the right compiler.

Categories : Python

AWS : S3FS AMI and load balancer high I/O Issue
I would like to recommend to take a look at the new project RioFS (Userspace S3 filesystem): https://github.com/skoobe/riofs. This project is “s3fs” alternative, the main advantages comparing to “s3fs” are: simplicity, the speed of operations and bugs-free code. Currently the project is in the “testing” state, but it's been running on several high-loaded fileservers for quite some time. We are seeking for more people to join our project and help with the testing. From our side we offer quick bugs fix and will listen to your requests to add new features. Regarding your issue: I'm not quite sure how does S3FS works with cached files, but in our project we try to avoid performing additional I/O operation. Please give it a try and let me know how RioFS works for you !

Categories : Amazon

AWS EC2 Instances with Load Balancing during very high traffic
Reserved instances are there to save money for those instances you regularly run. I would suggest using reserved instances for your 'master'. The only advantage of keeping that one on-demand is the advantage that you could scale up or down as soon as your constant flow of traffic changes up or down. Make sure you choose the right use for your reserved instance; an 'always-on reserved instance' should have an heavy-use reserved purchase. Those 'peak instances' do best as an on-demand instance.

Categories : Amazon

Optimize load time in a website (200+ product images at the same page)
Use LazyLoad LazyLoad And other similar jquery plugins

Categories : Jquery

Unique index on PostgreSQL text column - can it cause high CPU load?
For my personal views: yes; the unique index on a text a column is hurting the performance,especially when many INSERTS/UPDATES happen on the table. If your query does not need the unique index, I suggest you drop the unique index.

Categories : Database

syntax error near unexpected token `fi' - High load Notification mail
I don't really get the same error than you but you can already test this solution: if [ `uptime | awk '{ print$11 }' | cut -d. -f1` -gt 1 ]; This condition try to compare a float with an integer. I would make this test with an extended test command. And you can forget semicolon if you don't put then keyword on the same line than your condition : if [[ `uptime | awk '{ print$11 }' | cut -d. -f1` > 1 ]] then mail -s "$SUBJECT" $TO < /tmp/load exit fi

Categories : Bash

show only one series data in High charts in start of drawing/load
I think I found solution visible: false in series, updated my jsfiddle series: [{ name: 'MyHiddenLine', data: [1,2,3], visible: false },

Categories : Javascript

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

Optimize SQL Server Query
SELECT `current`.`InvoiceDate`, `current`.`TotalCost`, `prev`.`TotalCost` AS `PrevTotalCost`, (`current`.`TotalCost` - `prev`.`TotalCost`) AS `CostDifference` FROM dates `current` LEFT JOIN dates `prev` ON `prev`.`InvoiceDate` <= DATE_FORMAT(`current`.`InvoiceDate` - INTERVAL 1 MONTH, '%Y-%m-01'); Screenshot of the results I got: http://cl.ly/image/0b3z2x1f2H1n I think this might be what you're looking for. Edit: I wrote this query in MySQL, so it's possible you may need to alter a couple minor syntax things for your server.

Categories : Sql Server

How to store an array in the value for Key value pairs of redis server?
I would recommend using a list or a set. I would use a list unless you need duplication checks (if so then use a set). All the following examples are list based but you can find the equivalents for set here. Adding a new socket ID client.lpush(username, socket.id, function(err) { console.log('Prepended new socket ID to list'); }); Getting all socket IDs for a user client.lrange(username, 0, -1, function(err, socketIds) { }); Removing a given socket ID client.lrem(username, socketId, 0, function(err) { }); (I've assumed you're using the node_redis lib).

Categories : Node Js

HTTP Server with Redis Event Loop
Why do you think this thing is a HTTP server? It is not. It is a broken TCP echo server. It is broken, because the write operation is not under the control of the event loop. Some bytes will be lost if the non blocking write operation cannot send all the bytes (you have no such guarantee). Now, if you use a proper client, this program can still be demonstrated: $ telnet 127.0.0.1 8000 Trying 127.0.0.1... Connected to 127.0.0.1. Escape character is '^]'. toto toto titi titi tutu tutu ... while the output of the program itself is: Accepted 127.0.0.1:48645 If you want to play with event loops, I would suggest picking one among the following list. They are probably much better documented than the first random ae hack found on github ... libevent libev libuv

Categories : C

Best way to optimize image before uploading to server
thanks your for your feedback. Here is what I decided to do and is great in terms of performances : resizing to the wished resolution, then and only then do iterative compression until reachning the wished size. Some sample code : //Resize the image float factor; float resol = img.size.height*img.size.width; if (resol >MIN_UPLOAD_RESOLUTION){ factor = sqrt(resol/MIN_UPLOAD_RESOLUTION)*2; img = [self scaleDown:img withSize:CGSizeMake(img.size.width/factor, img.size.height/factor)]; } //Compress the image CGFloat compression = 0.9f; CGFloat maxCompression = 0.1f; NSData *imageData = UIImageJPEGRepresentation(img, compression); while ([imageData length] > MAX_UPLOAD_SIZE && compression > maxCompression) { compression -= 0.10; imageData = UIImageJPEGRepr

Categories : Iphone

Optimize SQL Server Aggregation Query
Try this one (for 2008 and higher) - SELECT [Place], COUNT(1) FROM ( SELECT [Place] = REPLACE(REPLACE(t.[Place], 'T', ''), '*', '') FROM dbo.mso_scores r OUTER APPLY ( VALUES (EventPlace1), (EventPlace2), (EventPlace3), (EventPlace4), (EventPlace5), (EventPlace6), (AAPlace) ) t([Place]) WHERE r.usagnum = '274246' AND r.TeamResult = 'N' ) d WHERE d.Place IN ('1', '2', '3') GROUP BY d.Place For additional information read this topic: Tips for SQL Query Optimization by Analyzing Query Plan

Categories : SQL

what is the mean difference between Nest and redis-namespace gems when we use redis with rails/ruby
You know http://redis.io/commands/select for he parallel running of multiple databases on one server? Here you don't have a key conflict and the databases are separated. Only if you access to keys from all databases at once it's not possible.

Categories : Ruby On Rails

how to save data from redis to a file in disk and read back to redis?
What you are looking for is Redis Persistance. You might want to checkout commands like SAVE or BGSAVE which dump data to disk as rdb files. These files can later be used to load data into redis on startup

Categories : C#

posting data from android to rails using Redis server
handling the request asynchronously is usually done when you expect something slow to happen sometimes inside the request (like calling a 3rd party service). In your case, all you will do is insert a record into the database, so you don't really need to handle anything asynchronously unless you're going to use a distributed database system or something very complex. A normal SQL server will easily handle a few thousands of inserts per second (unless you have large and complex indexes affecting them), so this shouldn't be a problem at all.

Categories : Android

Redis publish in rails 4 stops server thread
Don't use one connection in initializer to subscribe and publish both. I created 2 connections, 1 for subscribe in sse writer, 1 in controllers to publish, and everything working normally.

Categories : Ruby On Rails

Server high ping with Node.JS
The most common problem is when someone connects, your logic in node.js blocks and holds execution cursor, and then releases it after some delay that involves every other callback to wait. As node is async and single threaded process, you should avoid any blocking operations as much as possible. Use async operations with MySQL, and make sure all your internal logic is not blocking. Although more information regarding your logic would be helpful.

Categories : Node Js

High performance socket server (like MMO)
There: C# SocketAsyncEventArgs High Performance Socket Code; based on things I have learnt from this (and some other resources) I have written a high performance TCP server which is handling more than 7000 clients. Edit: Other good .NET code bases I studied to some extend are fracture (F#), SocketAwaitable and SuperSocket. I especially like fracture because of it's simple (not naive) and smart buffer pool handling but (as the version I've worked with) it does not provide a separate pool for acceptors; which I've done myself easily based on the already provided pool.

Categories : C#

TCP/UDP high-performance server under linux
Your basic approach is right. Start by studying the infamous C10K problem and how it was overcome. Once you understand the major bottlenecks in various implementations, you need to consider the following as part your design process : Minimise thread creation/deletion cycles. Always choose an "event-based" model over a blocking model. Basically the one-thread-per-request model is preferred for its simplicity of implementation. But it does NOT scale well with the number of concurrent requests. When designing systems required to support more than a few 1000 concurrent requests, one prefers the use of sockets over threads. The optimum number of "worker-threads" to instantiate depends upon : Load (number of concurrent requests) System (CPU, RAM) Since this is a very popular probl

Categories : Linux

How do I send an arbitrary command to Redis with the ServiceStack.Redis client?
The easiest change is to make the change directly in the ServiceStack.Redis project code. You'll want to change Commands.cs Change this from: public readonly static byte[] Publish = "PUBLISH".ToUtf8Bytes(); to: public readonly static byte[] Publish = "HSILBUP".ToUtf8Bytes();

Categories : C#

How to optimize a SQL Server query with repetitive sub queries
You can use CASE statements to eliminate the redundant subqueries, something like: SELECT various, other, native, columns, (SELECT client FROM clients WHERE id = clientid) AS client, (SELECT name FROM categories WHERE id = (SELECT categoryid FROM clients WHERE id = clientid)) AS category, (SELECT fullname FROM staff WHERE id = producerid) AS producer, ISNULL((SELECT SUM(amount) FROM JobsVoiceWork v WHERE v.jobid = j.id),0) AS voicecosts, (SELECT COUNT(*) FROM Scripts s WHERE s.jobid = j.id) AS numberofscriptscompleted, ISNULL(SUM(t.duration),0)/60 AS totaltime, ISNULL(SUM(CASE WHEN t.jobeditid = 3 AND t.jobpart = 'Add' THEN t.duration ELSE 0 END),0)/60 AS PartAdd, ISNULL(SUM(CASE WHEN t.jobeditid = 3 AND t.jobpart = 'Update' THEN t.duration ELSE 0 END),0)

Categories : SQL

SQL Server - Optimize this query with million records
You should be able to get rid of the HAVING clause: Select * from Forex where Id in (SELECT MAX(Id) FROM Forex GROUP BY Symbol) you could also try this version: SELECT * FROM Forex F WHERE Id = (SELECT MAX(Id) FROM Forex WHERE Symbol = F.Symbol) though I wouldn't expect it to be dramatically different. Some broad strokes (some may work, some may not): Make sure you have indexes on Id and Symbol, Id DESC. If the index on Id can be CLUSTERED it would help as well. Don't return all columns if you don't need to. De-normalize the table by moving Symbol to another, smaller table Add memory Add CPU Use faster hard drives

Categories : SQL

Need tips to optimize SQL Server stored procedure
Try right clicking within your stored procedure and check the Estimated Executon Plan. You can see how "expensive" your SP will be. If need be you could try http://stackoverflow.com/a/797968/1504882

Categories : SQL

Server sent events with Flask/Redis: how can more than one client view a stream?
It turns out that this is something to do with the Chromium web browser, where I was testing. It holds back on making the request until the first one completes, for some reason. Using curl, or an incognito browser session allowed multiple sessions to run at the same time. This means that my problem doesn't really exist in reality, it just appears that way because of the way that Chromium handles simultaneous requests to the same resource. I'm not sure quite why Chromium behaves this way, it seems weird. Either way, this isn't a real problem, only a perceived one by my browser.

Categories : Python

How to run Resque workers on different servers but polling jobs from one redis server
You'll just need to configure Resque to connect to a specific Redis instance. By default Resque tries to connect on localhost. Just create or modify a config/resque.yml as described here. It will probably need to contain something like this: production: my-one-and-only-redis-instance-address.com:6379 You'll probably want to make sure the redis server accepts connections only from the servers you have resque workers on using IP filtering at the OS level.

Categories : Ruby

How to connect redis-cli on Windows to redis on Linux (on VMware)
Sounds like a networking/firewall issue. You should connect to the redis server through redis-cli the same way no matter what operating system the server and client are on. This should always be redis-cli -h [ipAddress].

Categories : Linux

Rails server not starting with web sockets and redis options in rake task.
Hey thanks for the question, I personally couldn't get a rake task of mine to post to a websocket channel I had open on my rails server. Your synchronize command helped (along with starting a Redis server locally). Your problem through - seems like you're pointing to 3000. Is that your rails server or the Redis instance? If you're running it locally, I'd omit that line.

Categories : Ruby On Rails

How many ways huge data can be optimize in table sql server
300 columns sounds like quite a lot for one table. Perhaps the data should be normalized into several tables. Take note - normalization can cause performance problems itself, particularly because of large SQL joins, so perfect normalization is not always the best solution either. Finally, once you find a possible solution or two, I would call the interviewer with your findings and ask if there was another solution that you missed.

Categories : SQL

SQL Server 2012 Always on has high logcapture wait type
Don't troubleshoot problems on your server by looking at total waits. If you want to troubleshoot what is causing you problems, then you need to look at current waits. You can do that by either querying sys.dm_os_waiting_tasks or by grabbing all waits (like you did above), waiting for 1 minute, grabbing all waits again, and subtracting them to see what waits actually occurred over that minute. See the webcast I did for more info: Troubleshooting with DMVs That aside, HADR_LOGCAPTURE_WAIT is a background wait type and does not affect any running queries. You can ignore it.

Categories : Sql Server



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