function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Divya Gour 10Divya Gour 10 

Improving the performance of future methods by converting into platform events

Hi Folks,
 
Recently, we got a requirement of improving the performance of out future methods. There were few future methods which were taking around 22448 ms. 
I have implemented the solution for this below:
 
Whenever future methods are being called, publish a platform event. The platform event is subscribed by a flow which in turn calls that same future method, now converted as InvocableMethod.So, the callout which was occurring in the future method is now happening in the invocable method.
 
Please share your thoughts, if this solution is good and efficient?
Shiraz HodaShiraz Hoda
Hi Divya,

I implemented something similar but implementation was quite different. 
1. Platform event record was inserted through trigger or any class for which we wanted to call future callouts unlike yours where you are 2 times calling same future methods.
2. From platfrom event trigger a future callout was made.

so in short future will be just one and everything else was done by platform event.

this was pretty straight forward and no issues till date.

If this helps, Please mark it as best answer.

Thanks!