Generally, other than run your Photos library what kine of work do you do with your Mac?
Remember, iCloud Photos is not an off computer storage facility. It's a syncing feature which lets you have the same library on multiple devices and any changes to one device will be reflected on the other devices and in iCloud.
With a 9 year old Mac you're pushing the envelope with it. It's about as old as I am, definitely vintage and in one year will be considered obsolete by Apple. Then you'll have difficulty getting parts if it needs repair.
I'd do what rkaufmann87 suggested and put the library on an external HD, preferably SSD. Also I'd consider getting a newer iMac. If budget is a concern Apple sells refurbished Macs as a discount but with new Mac warranties. That way if and when you get a new iMac you can take the EHD with you. Also, in the spirit of fair disclosure, I'm not a fan of iCloud libraries.
If you consider getting a new Mac do not get a 21.5" iMac. Get a 27" iMac as it allows users to upgrade the memory themselves at less than ½ what Apple charges. Get them from Crucial.com or MacSales.com.
Also get the largest SSD drive the budget can afford. 1TB is a good size. I have a 500 GB SSD but have numerous external SSDs for additional storage and booting into older systems.