News for hackers. Stuff that matters.
Re:How and why to make your software faster by collyw on Friday April 15, 2016 @08:00AM (#11503603)
Just buy a bigger box with double the memory?
Re:How and why to make your software faster by jeffasinger on Friday April 15, 2016 @08:57AM (#11503878)
Sometimes that doesn't help.

At work we were debugging why a process that is usually quite fast (< 5min) was taking close to 2 hours once we got to the load we predict for this coming fall.

We noticed the box it was running on was running out of memory, so we assumed resizing it to have ~4x the RAM would help, but surprisingly it didn't. The actual answer turned out to be algorithmic, and we were able to rewrite it to use an O(n) algorithm rather than an O(n^2) algorithm.

Re:How and why to make your software faster by mootothemax on Friday April 15, 2016 @09:28AM (#11504089)
>Just buy a bigger box with double the memory?

For what it's worth, a quite staggering number of sites I've fixed up have had databases with varchar ID columns, and no indexes anywhere.

Thankfully the DB sizes have been small enough that fixing this has taken a few seconds to a few minutes max of DB downtime, with instant, seriously-impressive-looking results afterwards.

Re:How and why to make your software faster by jimcsharp on Friday April 15, 2016 @09:51AM (#11504251)
I wonder when this type of work will go away. I see it everywhere.
Re:How and why to make your software faster by beachstartup on Friday April 15, 2016 @11:41AM (#11505173)
it will never. databases are hard and people are idiots. nevermind something as hard as SQL optimization and index design -- there are LOTS of people out there who think creating a new logical database for every new customer is a good idea, resulting in 2000+ databases on a system when there should be 4. people who think HA is a waste of money because nothing has ever failed on them. cheapskates who will under-spec deployments and then yell at you when it doesn't fit their data. people are stupid. do not underestimate the stupidity of your average tech industry "professional". this is why i think there should be a traditional engineering certification process for this stuff.

also, i simply don't buy the assertion that any ops or dev can be automated in any meaningful way. the only thing it's doing is making it easier for morons to shoot themselves in the foot by ignoring the experts and then run to the same experts like a little child when everything catches on fire. see: recent story of a guy who deleted 1500 systems at once. oops.

are we all doing more, or less work than 5 years ago? has all this cloud and deployment tech made any less work for anyone, or destroyed any jobs? lol no. i repeat emphatically LOL NO. such a claim is just absurd in my view. anyone who claims such a nonsensical statement has never done actual ops work where you get called if shit goes south.

the smartest thing amazon ever did was simply give people a button to push to give them more money when they're faced with their own overwhelming stupidity. ain't nobody to blame but yo'self then.

Re:How and why to make your software faster by ben_jones on Friday April 15, 2016 @12:47PM (#11505710)
On the flip side, learning resources will continue to improve. Now days all one would have to do is google "database optimizations" and immediately see things like indices etc. Furthermore if they're using a framework, which most are, the search becomes "how to speed up django" which leads to a lovely documented page hand holding you through whatever you need to do.
Re:How and why to make your software faster by leesalminen on Friday April 15, 2016 @12:04PM (#11505350)
> there are LOTS of people out there who think creating a new logical database for every new customer is a good idea, resulting in 2000+ databases on a system when there should be 4.

I'm genuinely curious as to why you feel this way?

Re:How and why to make your software faster by bpchaps on Friday April 15, 2016 @12:23PM (#11505503)
An ungodly amount of reasons. The ability to manage that many, for one. Those poor devops folk who have to deal with that.

On a more technical side as an example, the number of open files can only be so high. You really start to hit the limit when you do things like that, which is when the most interesting kinds application crashes happen. "Just increase the file count." results in "Our report shows that an OldServer did not include a necessary open file limit config change. Engineer #582 has been fired."

Re:How and why to make your software faster by leesalminen on Friday April 15, 2016 @01:05PM (#11505882)
CLI tooling has solved a lot of the problems that arise from many. Scripts for migration, host transfer, creation and deletion took some time to build out, but do work fine.

I suppose we are lucky to have a very consistent workload per logical database.

This allowed us to calculate our costs ahead of time. We found that we could keep DB costs at ~$1/customer/month. For a B2B SaaS product we were satisfied with that cost.

Re:How and why to make your software faster by joncampbelldev on Friday April 15, 2016 @12:27PM (#11505546)
My personal preference for a single multi-tenanted schema as opposed to 2000+ schemas is: Unless you require per customer customisations (which is a fast way to ensure you have an upper limit on the number of customers you can support) there is no need to duplicate. Use a single schema where every table with per-customer data has a tenant id column.

Most decent RDBMS have a good way to ensure isolated locks across tenant ids e.g. MySQL partitions.

Re:How and why to make your software faster by leesalminen on Friday April 15, 2016 @01:02PM (#11505858)
Understood.

Currently, I manage several hundred logical databases for a B2B SaaS product. This has the potential to grow to several thousand over the course of years.

My customers enjoy that (arbitrary) piece of mind that their data is logically separated from all else. I enjoy not having to remember to include a tenant_id clause.

Our traffic pattern is quite steady per hour of day and per customer. That, plus using RDS for horizontal scaling (fixed # of logical DBs per host) allowed us to take this route.

I suppose the decision is a matter of circumstance and preference, but I don't think this is necessarily "wrong" to do.

Re:How and why to make your software faster by beachstartup on Friday April 15, 2016 @02:42PM (#11506626)
it's going to work fine until it doesn't. that's not going to be a good day. smart people can rationalize anything.
Re:How and why to make your software faster by beachstartup on Friday April 15, 2016 @12:05PM (#11505358)
see? LOTS.
Re:How and why to make your software faster by CaptSpify on Friday April 15, 2016 @10:05AM (#11504349)
When companies figure out that hiring "one guy that can do everything by himself!" is a bad idea. So...... not likely anytime soon.
Re:How and why to make your software faster by mgkimsal on Friday April 15, 2016 @10:44AM (#11504698)
Except... sometimes one guy really can do everything by himself, and do it much better than the other folks. However, usually the person who can do that is "too expensive" and they'd rather spread the cost (or a higher cost) over 3-4 people.

It's not just talent/skills - there's more communication overhead when dealing with a team, and when the team has a range of skill levels on it, the comm overhead can make things worse (if not managed well)

Re:How and why to make your software faster by Joeri on Friday April 15, 2016 @01:34PM (#11506152)
I have seen the one guy replaced by a team of 5. The team got less done than the guy.

I have a longstanding suspicion that developer cost climbs slower than developer skill and productivity, meaning companies should always hire the best they can get, because they'll maximize productivity that way.

Re:How and why to make your software faster by sokoloff on Friday April 15, 2016 @06:59PM (#11508245)
IME, it climbs WAY slower.
Re:How and why to make your software faster by collyw on Friday April 15, 2016 @01:18PM (#11506000)
I am the one guy fixing these things all by myself.
Re:How and why to make your software faster by Piskvorrr on Friday April 15, 2016 @08:03AM (#11503613)
That's the easy way out - therefore, step 0. Step 1 is "we tried throwing hardware at it, didn't help a lot, now what?" ("Well throw more hardware then" rarely gives a measurable improvement.)

To the downvoter: Maybe in your fantasy world, throwing more computing power at problems solves Eeeverything, including P ?= NP. I do wonder - why people even bother offering such services as the OP, if it's so pointless?

Re:How and why to make your software faster by dr_zoidberg on Friday April 15, 2016 @09:25AM (#11504064)
I think you may have been downvoted because the article just explains: step 0 should always be profiling and then deciding what you need, either more hardware or better code.

I once spent weeks optimizing code on a "best in the world" (for my branch of work) open source project because it made the assumption that it'd run on SSDs, hence it made zillions of small reads from the disk. There were two approaches to solve that: buy an SSD, or refactor the code. But it was through profiling that I found the answer (and in my economic situation at the time, buying an SSD was definitely not viable, much less a step 0!).

Re:How and why to make your software faster by pjc50 on Friday April 15, 2016 @09:55AM (#11504278)
Hah. Why think when you can spend money?

Firstly, this doesn't help if you're CPU-bound or write-bandwidth-bound, both of which are quite common.

Secondly, you may not be able to simply get a bigger box. Most motherboards have effective RAM limits. Bigger iron gets exponentially more expensive. Jeff Atwood on this: http://blog.codinghorror.com/scaling-up-vs-scaling-out-hidde...

(I remember about a decade ago when our chip design startup bought a 128GB RAM box because that was the largest available at sane pricing ...)

Re:How and why to make your software faster by phkahler on Friday April 15, 2016 @09:24AM (#11504059)
Some companies box is a warehouse with rows of racks of servers consuming hundreds of kilowatts, if not a megawatt. Those are exceptional cases, but it helps to point out how "just buy a bigger box" eventually has limits.
Re:How and why to make your software faster by jstanley on Friday April 15, 2016 @08:03AM (#11503619)
Unless the box is heavily overloaded, that won't help. Profile it and see what needs fixing!
Re:How and why to make your software faster by MrFoof on Friday April 15, 2016 @11:30AM (#11505086)
Fun things I discovered in just my last performance tuning engagement:

* Database with homegrown software load-balancer in front of it, and the database replicated to a half-dozen subscribers. Load balancing required database calls, and the subscribers had their LUNs on the same array as the main database. So 7 different servers, but all beating the same storage. In the end, we ended up with no load balancing (just the single instance).

* Application server with lots of agents (one on every workstation). Agents were checking in every 200ms, even if they had nothing to report. Result was lots of tiny database transactions (for logging no activity). Throttled that down to 10 seconds (product managers agreeing that was the more realistic threshold) and batching the updates, made the logging asynchronous, and saw the database transaction log no longer waiting on log writes constantly.

* Bad clustering keys for tables. Some tables that were being searched constantly as heaps. Sharded tables with divergent schemas. This was fun, as had to conform everything while it was live (got agreement on what was reasonable delay for synch jobs). Chose correct clustering keys, compressed the tables, and then got rid of other indexes that were no longer necessary. Cut IO by 99%, and writes were now just appends.

* Badly written queries using inadequate indexes on badly structured tables. TL;DR: An analysis process took 24 hours, and was tuned to take 4.5 hours. I spent a day on it to cut it down to an hour while I worked on other things. We then spent 2 weeks refactoring it to cut it down to about 8 minutes, despite the underlying data model being bleh. We also added ad-hoc functionality to do stuff out-of-band of the regular scheduled job, with an average response time of 6ms.

* ORM lazy loading by default, including for things that constantly retrieved collections. Rewrote them to be programmatically eager loaded and reduced database calls from millions a day to thousands a day.

* And a little bit of hardware. SAN HBA links were moved form dual 1Gbps to dual 10Gbps. Some SSDs added. Ended up reducing IO latency by 96-98%, depending on the server. Needed to happen, as IO latency was in hundreds of ms, and we were able to get it down to where it should be (< 10ms for reads, 1-3ms for writes).

Non-scaling SAAS stack went from falling on its face with an entire rack of hardware, to being cut down to 1/3rd of a rack of hardware and the hardware basically twiddling its thumbs. The organization was in the process of building of entirely new SAAS platform in a completely different tech stack -- they immediately started questioning that decision when the old stack handled everything trivially, and they knew there was a lot more tuning that still could be done.