You could try going into your 3DS internet settings and setting your MTU to 1500. Default is at 1400 I believe. Made a huge difference to me, as before I couldn't get into a single online race at all, no matter how often I tried. Since then, I haven't had a single bit of difficulty.
Of course, this solution may not work for everyone, but it did for me.
Nintendo Network ID: Cheebee 3DS Code: 2320 - 6113 - 9046










