How to prevent context deadline exceeded error

How would I go about preventing context deadline exceeded error from happening when my activity returns a large amount of data.

The activity works fine when the XML file size is around 1mb, but when I try to process a XML file that around 7mb I get an context deadline exceeded error.

The file is processed and everything works until it tries to return the file so the next activity can use it. Then it hangs and return the above error.

You have a default 2MB blob size limit (which translates to single workflow/activity input and their result). If you need to pass large data from workflow to activity and vice versa or return large data back to client one practice would be to store this data in custom blob store and then pass references to it rather than the data itself.