r/SQLServer • u/Forsaken-Fill-3221 • Oct 19 '25
Discussion Databse (re) Design Question
Like many, I am an accidental DBA. I work for a company that has a web based software backed by a Microsoft SQL Server for the last 15 years.
The last hardware upgrade was somewhere around 2017.
The database is about 13TB, and during peak loads we suffer from high CPU usage and customer reported slowness.
We have spent years on optimization, with minimal gains. At peak traffic time the server can be processing 3-4k requests a second.
There's plenty to discuss but my current focus is on database design as it feels like the core issue is volume and not necessarily any particularly slow queries.
Regarding performance specifically (not talking about security, backups, or anything like that), there seem to be 3 schools of thought in my company right now and I am curious what the industry standards are.
- Keep one SQL server, but create multiple databases within it so that the 13TB of data is spread out amongst multiple databases. Data would be split by region, client group, or something like that. Software changes would be needed.
- Get another complete SQL server. Split the data into two servers (again by region or whatnot). Software changes would be needed.
- Focus on upgrading the current hardware, specifically the CPU, to be able to handle more throughput. Software changes would not be needed.
I personally don't think #1 would help, since ultimately you would still have one sqlserver.exe process running and processing the same 3-4k requests/second, just against multiple databases.
#2 would have to help but seems kind of weird, and #1 would likely help as well but perhaps still be capped on throughput.
Appreciate any input, and open to any follow up questions/discussions!
9
u/dbrownems Microsoft Employee Oct 19 '25 edited Oct 19 '25
Whether #1 will help depends on your query plans. Particularly whether 1) some "shards" would benefit from shard-specific query plan optimization, and 2) whether current plans require scanning data that would be removed from the database.
If you haven't had a hardware upgrade in 8 years, it's overdue. You should probably start there and then evaluate your additional options. Faster CPUs, more RAM, and flash storage might help a lot.
4
u/Far_Swordfish5729 Oct 19 '25
In these situations it is critical to look at the database statistics to determine whether you are IO, cpu, or memory bound and focus there. With volume inserts it’s likely you are IO bound but you need to confirm this. If so, I would try to partition the tables so you can write to multiple storage locations in parallel to speed up throughput. You should also make certain that your insert heavy tables don’t have unused indexes that have to be updated and that they are clustered (physically stored) in insert order to avoid page fragmentation. If your clustered PK is not in order (like a guid), consider clustering on something that is like a date stamp or a guid column using newsequentialid() rather than newid().
Secondarily, if this load is spiky, strongly consider using an input queue with a semaphore throttled reader to limit concurrent writes and smooth out traffic.
Also, if your write load does not solely come from web traffic, consider maintaining a separate server to serve web clients from your input load receiving master and accept that they may be slightly out of sync. I’ve implemented that to improve web latency. You can also use a denormalized, pre-transformed web schema that closely matches the page nav to further speed reads up to essentially creating json payload by id for commonly accessed customer pages.
4
u/jshine13371 6 Oct 19 '25
Your bottleneck isn't a limitation of the
sqlserver.exeprocess. It can handle way more transactions than that.Number 2 makes sense when you start hitting large numbers of databases for one instance, because there more concrete limitations with that metric that eventually makes it untenable. The most I've had on a single instance was around 300 databases. So it's definitely not "weird" when the use case is there.
You're very likely a long way away from being capped on throughput due to hardware limitations. The above aforementioned instance with 300 databases had individual tables in some of them that were multi-terabyte and 10s of billions of rows big. Most queries ran in sub-second runtime even during high concurrency. The hardware behind that instance?...4 CPUs and 8 GB of Memory (eventually got them to bump it up to 16 GB of Memory).
There's basically 3 levers you can pull to optimize a database: 1. Tune the queries and indexes, 2. Re-architect the system (schema design and process / use cases), 3. Bump up the hardware. Usually #3 is the least efficient answer and most costly, but quickest to change at least. In all honesty, you're probably not at the point where #3 is the best answer. But best of luck either way!
3
u/SQLBek 1 Oct 19 '25
Frankly, would need to know far more details about your workload's specific bottlenecks to make recommendations.
Without additional details, number one may or may not benefit you - but that one depends heavily on workload patterns & data usage. I would advise against that one unless you know for damn certain that that'll help.
Throwing more hardware at a problem will only ever get you so far before the benefits plateau and you must bite the bullet of code & database schema refactoring.
Frankly, your dollars may be best suited by hiring a performance tuning specialist consultant. They'll be able to guide you best.
3
u/No_Resolution_9252 Oct 19 '25
You don't really put any usable information in here other than the age of the hardware.
You mention that years have been spent on optimizations to no result, but have any of the optimizations actually been successful? Who is doing the optimizations? Developers? If Devs are doing it, I would expect, a mixed bag of small performance gains and massive performance regressions that they will unlikely be able to recognize.
3-4k queries per second is brisk, but well below what SQL server and hardware from a decade ago could handle.
I don't think anything involving the infrastructure is worth doing other than upgrading the hardware. Its time to upgrade it, its beyond its useful service life and a lot of performance gains have been realized since then. Your upgrade should have already been done at this stage and it could easily take a year to upgrade. While you do this, question things like the number of numa nodes, amount of memory per numa node, total amount of memory in system, TempDB performance, If it is virtualized, ensuring the host is not oversubscribed (one logical core to one virtual core), assessing parallelism, etc.
On the DB side, there are many things that could be negatively impacting the performance of SQL server that are purely in SQL: excessive constraints, over-indexing, under-indexing, inadequate stats maintenance, excessive parallelism, insufficient parallelism, inappropriate trace flags, etc. This is all before you start getting into the queries themselves. do you have developers that are afraid of aggregates and insist on using a labyrinthine mess of CTEs? Are a lot of UDFs used? Do you use DISTINCT anywhere at all? Does no lock/read uncommitted get peppered around to "fix" performance issues? Are recompile hints used regularly? etc
2
u/Comfortable-Ad478 Oct 19 '25
Item #3 What is the current CPU and RAM of hardware?
2
u/FreedToRoam Oct 19 '25
First just right click the server, choose reports, performance blah blah report. This will give you cpu usage but on the right side towards the bottom it will give you link to missing indexes.
I would like to know HOW MANY missing indexes is thinks you have?
While the suggested indexes aren’t all necessary, by knowing how many would give us an idea how much of a problem you have. I believe it does lists the most needed indexes first. You can right click it and export to excel and then copy the column with the scripted indexes and paste it into query analyzer
2
u/throw_mob Oct 19 '25
well, you mention well known names in consulting side , so i have to assume that best practices are done as they should be.
changing from 2012 to 2014 and so on (if you also change fileformat )gave 10%ish more performance, so that could help too and change from 2016 to latest one. hardware is from 2017, so it could be time to upgrade hardware as it is 8 year old.
So, i would start with new hardware, latest sql server version and then back to internals, I always find it easier to split monolith database to multiple schemas and then start to think all those schemas as own applications and dataset ( and consider them as own microservices).
you can always forget hardware and just dive into internal rebuilding, but in 5 year plan i think there has to be hardware upgrading anyway , so that will help to take biggest pressure from performance ( or it should )
tldR; upgrade hw and software and do 1. and split all to own schemas first if you are in classic everything is in dbo schema, if you manage separate some parts to own independents service , start to move onto own databases and own servers but imho , you have to travel whole part, if you try to jump straight from a to z you probably fail harder and costlier manner than just slowly changing existing thinking.
Of course there is always option to use read replicas and adding more caches to backend/middleware side , so that it wont hit database everytime etc etc , but cannot comment those with given information
2
u/gumnos Oct 21 '25
I couldn't tell from your description how those 3–4k requests broke down in terms of
SELECTvsINSERT/UPDATE.Your #3 is low-hanging fruit. If you're not network-bound, throwing a couple grand at beefier hardware will buy you extra time to explore other options, and possibly alleviate the problem altogether for now.
For your suggestion #1, it would likely only help if there was write-contention for certain tables that could be partitioned (like your #2 option). If 20 customers are all trying to update one
OrderLineItemstable, and lock-contention is high, then creating separate databases could reduce the load on any single database to that customer's specific load.But if you're going to go to the trouble of implementing multiple databases on the same machine (your #1), you might as well make the almost-identical software changes required to do #2, sharding the high-volume tables across 2+ servers in some fashion that makes sense based on the queries/data/table/load you're seeing. Usually partitioned by Customer but there might be other sensible ways to slice it up.
1
u/Hairy-Ad-4018 Oct 19 '25
Can you post your current hardware specs ? Is the db slow when saving or reading ?
Which version of sql Server are you running ? Which os?
Have you profiled the db? Do you have index’s ? Primary keys ? Do you regularly defrag the indexes ? What’s your disk I/o like ? Is there a dedicated nic for sql server ? Are there clustered indexes on each table ? Any parameter sniffing ?
There are many troubleshooting steps you can take to help isolate the problems.
1
u/B1zmark 1 Oct 20 '25
Do you run SSD's?
1
u/0110001001101100 Oct 21 '25 edited Oct 21 '25
Have a cluster and offload read queries to the replicas - assuming writings are not the bottleneck. And like others said, hardware upgrade might be low hanging fruit.
1
u/Informal_Pace9237 Oct 21 '25
QQ.
Would you be able to share your server hardware specs?
How many tempdb do you have?
Do you use SP/Functions or plain SQL?
1
u/KickAltruistic7740 Oct 22 '25
Honestly if your database is 13TB in size I hope you have partitioned the tables and added extra files to the file group.
1
u/ClassicNut430608 Oct 28 '25
I am late on the party; thus I may have missed many excellent comments. Given the terse information, I would tend to 'model' the situation.
a) assume your WEB is the fixed original START. Using your 'staging' copy:
b) draw the I/O and data flows between your START and your back-end database
c) on a 'small' -- different server (nothing big beyond a recent lap-top) create a new database with the minimal number of objects to handle the key 'flows' found in b) You can copy the objects, with only the PKs. No indices.
d) looks at the Statistics and Execution plans as you model your reality in that clean database -- see the indices suggestions.
e) After analysis, compare your model table schemas, triggers, PK and FK, with your actual system
f) Then you can start figuring out a plan of migration, if need be.
Our migration plan would have been costly thus:
On our smaller database (a few TB), we were saved by increasing the memory footprint, substantially ($$$$$) and going to SSD ($$$), as we found that the rewriting cost would far exceed the new hardware costs. In fact, we postponed our pain.
In the longer term, we are stuck with a) add small dbs to handle 'narrow' functions', b) Integrate these with our front- and back-end, allowing for some code duplication and c) having a complete mess on our hands.
3
u/carlovski99 Oct 20 '25
3-4k requests a second is quite a lot. Especially if its a very mixed workload as you say. That's ~200 requests a second per thread, but don't forget that hyperthreading isn't really as good as a physical core, especially if the server is fully saturated.
If your queries aren't completing in 5 ms, then things are going to be queueing.
Best way to handle this kind of thing is to offload some of that activity, i.e cache some of the data either at an application level, or by putting in a caching layer on something like Redis/Memcachdb. Obviously either would require a lot of effort by your developers/testers. And would depend on how critical it is to never see stale date.
Or, if you can identify specific requests that don't need to be 100% real time, and are 100% read only, you could look at setting up a read only replica to service those, hence offloading some activity.
If not, I don't normally advocate just throwing hardware at problems, but you are getting towards end of life on your current platform. Probably will need to replace sooner than later anyway, so might be worth at least costing it up.
-1
u/Maleficent-Will-7423 Oct 20 '25
Your current scaling options are temporary fixes for a problem that requires a new architecture. A distributed SQL database like CockroachDB is the modern solution.
Instead of making one server bigger (vertical scaling), CockroachDB lets you distribute the load across multiple servers (horizontal scaling).
• Solve Performance Issues: When CPU is high, just add another server (node). CockroachDB automatically balances the 13TB of data and 4k requests/sec across the entire cluster.
• No Application Changes: You can add nodes to increase capacity without rewriting your application.
• Always On: If a server fails, your database remains online and available.
This approach fixes the root cause of your slowdowns: the architectural limit of a single server.
CockroachDB’s MOLT (Migration Tools) is a purpose-built toolset that simplifies and automates the migration process from SQL Server, making the switch manageable and low-risk.
-1
u/No-Extent8143 Oct 20 '25
Stop whatever you're doing. You do not have factual information that is needed to make any decisions at this point. Go back and figure out what's going on.