5 Replies Latest reply on Mar 14, 2016 8:53 AM by ianban RSS
    hpulkkinen Explorer

    Best practices to run external functions

    I'm using a complicated algorithm to process sensor data. The algorithm creates and deletes around 100 new objects for every new measurement which happen on average every second. Therefore I don't think it would be efficient to implement this on Thingworx.


    The algorithm takes only the measurement (one integer) as the input and the output is a array of integers (variables for things on Thingworx). It seems viable to implement the algorithm as an external function which Thingworx will then call with all the measurements.


    I have been thinking about creating an application based on the gateway Edge Micro Server and to run that on another cloud server. This is probably not what the Edge Micro Server was designed for but it seems to get the job done. Or do you think there would be a better solution?

      • Re: Best practices to run external functions
        carlesc Ninja

        You can create a Server Side Extension in Java and do it on the same server, why not?

        • Re: Best practices to run external functions
          ianban Creator

          Edge microserver or SDK application is an option and would certainly give you horizontal scalability if you need multiple instances of it running.


          A few questions:


          1) What are you doing with the result data? It sounds like the resulting data gets sent to multiple things. What happens then? Are you storing the data in a stream/ValueStream?

          2) How many Things?

          3) How many of these properties per Thing? Or do you just need one instance of this service


          The ThingWorx server is pretty good at processing lots of data, I did a test a few months ago on a small virtual machine, I had 5000 virtual things created by 10 java SDK simulators, each Virtual Thing was sending a 30 character string to a property of a Thing on the ThingWorx platform on a supposed 5 seconds cycle. (It was taking a few seconds to create 500 30 character strings and send them to ThingWorx....) When the ThingWorx property was updated, it triggered a subscription that ran aservice to split the String into 10 3 character strings and push these into another 10 properties on the Thing.


          The VM had 8Gb RAM, Tomcat was configured to use 4Gb of this. The VM was running all of the simulator instances and ThingWorx and didn't get above 50% CPU usage. I wasn't persisting the information in a Stream or ValueStream. Doing this would increase the load somewhat but, if you're going to be writing that much data you use a separate machine for the persistence layer.





            • Re: Best practices to run external functions
              hpulkkinen Explorer

              1) The results are the location variables of Things. They are saved to the things and can later be visualized to the user with a map or such. They are also used for further calculations in Thingworx, such as calculating number of targets in some certain areas. Right now there seems to be no need to log the location variables, but this might change in the future.


              2) Number of these Things is equal or less than the number of connected devices, which is usually 50 - 500 per site.


              3) There is just one property per Thing (the location) so I need just one instance of the service.