If you need an ID just get an ID

If you are familiar with WordPress, you should already know that you should almost never have to use get_posts().
Your best bet is to use WP_Query . As good as wp_query is, you should still fine-tune it depending on your needs, it does make a difference. For example, if you just need 1 random post ID, just get 1 random post ID by making use of ‘fields’. See the results in the picture.
Of course that goes for all the other query args. Be specific as you can and get only what you need.