[SalesForce] the best approach to mass create records from a button click

My requirements are that I have to create a class that creates 400 to 600 records on a custom object once a button is clicked. I figure the best approach is to create a static webservice method that is called by a javascript button. I have done that before. The problem is I need to design this in such a way that scales well. Since I will be creating child records, the number of records I will increase over time. I've been reading and it looks like "Batchable interface" might be the way to approach this. But it looks like it is something than needs to be scheduled in advance rather than executing on user action.

So I'm just looking for advice as to how to build this out in such a way that is scalable but it needs to be a user pressing the button to initiate this action and not a scheduled job. Any input is welcome, thanks!

Best Answer

I would highly suggest creating an intermediary visualforce page where you explain to the user what is going to happen (maybe displaying the record that will be created etc). On that page would be another "Confirm" button. This would then allow you to use a Controller to take your inputs needed for the creation of the child records. You can then bulk process as needed,