Intermittent 500 errors are usually the result of an outage or system failure, so they likely aren't an issue with your code or data. You can't really avoid them either, in the real world. Retries are a good strategy, though for extended outages they may not work. Also, you should make your restlet calls idempotent wherever possible, just in case you accidentally retry a request that succeeded, but you didn't get a response. Then you can retry requests with confidence.
If you are getting them frequently, though, that could be a problem. You may then want to open a case with Netsuite.