This is probably the most likely cause when it comes to game console not working at its best. PS4 essentially is a custom built gaming computer with the same components as a powerful PC. As we all know powerful electronic things tend to function on high temperatures, which isn’t the best for those silicone APUs inside your game console.
The Accelerated Processing Unit (APU) is a device, which is soldered on the mainboard inside of your PS4. It is manufactured by AMD and hosts CPU and GPU inside of single component. So, during these gaming sessions your game console, specifically APU, can heat up to 90C degrees and needs to be cooled down. The cooling is completed via heatsink attached on top of APU, which is then further cooled down by pushing cold air via an integrated fan inside your game console.
Once any of these components do not function as they suppose to, e.g. poor heat transfer between APU and heatsink, faulty cooling fan or even dust accumulation causing insufficient airflow, your PS4 overheats. High temperatures inside your PS4 causes damage prevention mechanisms to kick in and throttle down APU operating speed, which is experienced as freezing or temporary lag on the screen.