Browsed by
Tag: suitelet

Epic Battle: Concurrent Map Reduce vs Concurrent Suitelet

Epic Battle: Concurrent Map Reduce vs Concurrent Suitelet

Spoiler: 50 concurrent Suitelet win. (Tested in Sandbox)

I am a big fan of Map Reduce scripts, spreading the load among 5 queues makes a huge difference when processing your data. Unfortunately to take advantage of the concurrent queues feature your account must have a SuiteCloud plus license.

So I figured it would be cool to simulate this feature with Suitelets. Suitelets support up to 50 concurrent connections and they are available without the need of SuiteCloud plus.

The results were very surprising.

Test scenario:

  • Task: Create and delete a custom record with no fields.
  • Account: Account with SuiteCloud Plus license in Sandbox.
  • Map Reduce: Run task 10k times by returning an array of 10k elements on the getInputData step and let the reduce step handle the main logic.
  • Suitelet SS2.0: Run task once per call. Return “OK” as response. Available without login (External).
  • Use Apache JMeter to call the Suitelet 10k times.
  • Additionally call the Suitelet using Ajax with browser (Chrome) 5k times (to avoid browser memory issues).

Here are the results:

testresults

 

Map Reduce w/buffer size of 1 : 196 seconds ~ 51 per second
Map Reduce w/buffer size of 64: 518 seconds ~ 19 per second
Suitelet w/JMeter w/50 at a time: 55 seconds ~ 181 per second
Suitelet w/JMeter w/100 at a time: 30 seconds ~ 333 per second
Suitelet w/JMeter w/200 at a time: 24 seconds ~ 416 per second
Suitelet w/JMeter w/250 at a time: 24 seconds ~ 416 per second
Suitelet w/JQuery: 1000/44 secs ~ 22 per second

As you can see, I ran multiple test variations. After I saw that the Suitelet was able to handle 50 requests at a time I went crazy and increased the number of concurrent requests. I got up to 250 requests being handled successfully. Once I reached 300 requests at a time I started getting errors and not all the records were successfully created.

As you can see, after 200 requests you pretty much get the same speed. This could be caused by my system, JMeter, my internet connection or by some throttling happening on the Netsuite side, I don’t know.

Conclusion:

This approach can be pretty handy if you ever need to process large quantities of records and you need even more speed than what Map Reduce gives you. You would need to develop your Suitelet in a way that even if something goes wrong you have a way to identify the errors and retry the operations. Additionally, you would need to get a tool that bypasses the browser restrictions such as Apache JMeter and configure it if you need to pass any data to the Suitelet.

Anyways, the difference is huge. Basically you could process 1 million records in 40 mins in the Suitelet vs 5:30 hrs in a Map Reduce… and this is in Sandbox, go figure how faster this would be in Production.

Live Chat Using Netsuite as Backend

Live Chat Using Netsuite as Backend

This time I decided to practice my skills by creating a simple live chat messaging system with Netsuite as backend and Bootstrap/jQuery as frontend.

I only used one custom record with 3 fields. Two fields (Timestamp and User) were set to default to current user/current datetime. So really the only field I had to write to was the message text.

The messages are sent via POST. I am using the jStorage jQuery library as a local DB to cache the messages. Messages are cached for 60 seconds by default.

The suitelet is being polled every 2 seconds. Every time the suitelet is polled a search runs that returns the last 20 messages created within the last 30 seconds. Clientside code checks for new entries in the db and if new entries are found the messages are displayed.

 

Here’s the code:

 

Loading custom HTML and bootstrap within a Suitelet Form

Loading custom HTML and bootstrap within a Suitelet Form

I want to share this nice hack I created to allow to run custom HTML within a Netsuite form. I am using it to load bootstrap and sweet alert, but it can be used for a lot more! In this example I am loading a basic bootstrap template, it can be tweaked to send POST messages to the suitelet and load more jQuery plugins and scripts.

The end result:

SuiteletHackBootstrap

 

Note: This is a hack, so beware.

Leave a comment if you liked it or think it can be improved!

Suitescript 2.x version

 

Suitescript 2.1 version