[SalesForce] Governor limits on http callouts

I am having to make a httpcallout from a VF page to get some data from an external source.
I can see there is a limit of 10 callouts per transaction

Total number of callouts (HTTP requests or Web services calls) in a transaction 10

What would a transaction mean?
Assuming i am making a http request on click of a button and once the request is completed i again click the button, would this amount to 2 callouts in one transaction or would be considered as 2 different transactions?

Best Answer

Salesforce provides a decent explanation of transactions:

What is an Apex Transaction?

An Apex transaction represents a set of operations that are executed as a single unit. All DML operations in a transaction either complete successfully, or if an error occurs in one operation, the entire transaction is rolled back and no data is committed to the database. The boundary of a transaction can be a trigger, a class method, an anonymous block of code, a Visualforce page, or a custom Web service method.

All operations that occur inside the transaction boundary represent a single unit of operations. This also applies for calls that are made from the transaction boundary to external code, such as classes or triggers that get fired as a result of the code running in the transaction boundary. For example, consider the following chain of operations: a custom Apex Web service method causes a trigger to fire, which in turn calls a method in a class. In this case, all changes are committed to the database only after all operations in the transaction finish executing and don’t cause any errors. If an error occurs in any of the intermediate steps, all database changes are rolled back and the transaction isn’t committed.

So, to answer your original question, that will be treated as two transactions. Clicking a button to fire off a single call works as one transaction that will complete. When you click it again, it will be another transaction.

Related Topic