For RESTlet processing that large, you will likely need to either:
a) break your processing into multiple RESTlet requests, each processing a different page or chunk of the results
b) have your RESTlet kick off a Map/Reduce, which will then send an async response back to your external system when complete