Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Solved
  • Unsolved
  • Users
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Darkly)
  • No Skin
Collapse
brainCloud Forums
  1. Home
  2. Cloud Code
  3. Shared Global Context for each CloudCode invocation?

Shared Global Context for each CloudCode invocation?

Scheduled Pinned Locked Moved Cloud Code
tuningscriptcloud codeloot
8 Posts 3 Posters 3.0k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Travis Brown-John
    wrote on last edited by
    #1

    Does each CloudCode call have some global/shared context?

    I'm thinking of global "tuning" data for a custom loot box system. Or would this be System Global Data? If it is System Global Data, then I suppose accessing the data would cost me 1 api call per invocation.

    Thanks,
    Travis

    1 Reply Last reply
    0
    • Paul WinterhalderP Offline
      Paul WinterhalderP Offline
      Paul Winterhalder
      brainCloudAdmin
      wrote on last edited by
      #2

      Hi Travis,

      You have a few options:

      • Global Entities - simple, basic API - but not very scalable. Definitely make sure you have < 1000 entities.
      • Un-owned Custom Entities - more scalable, custom indexes, etc. Requires plus plan
      • Global Properties - store simple strings and smaller JSON objects

      Those would be the main options. And yes - accessing them uses API calls - but remember, you get 3 free API calls in a script - and every call from then on is just 1/2 a count.

      So if you have a script that makes say 5 API calls - it will actually only cost you 2 API counts: 1 to call the script, 3 are free, and the remaining 2 calls are 1/2 each.

      Hope that helps!

      Paul.

      T 1 Reply Last reply
      0
      • Paul WinterhalderP Paul Winterhalder

        Hi Travis,

        You have a few options:

        • Global Entities - simple, basic API - but not very scalable. Definitely make sure you have < 1000 entities.
        • Un-owned Custom Entities - more scalable, custom indexes, etc. Requires plus plan
        • Global Properties - store simple strings and smaller JSON objects

        Those would be the main options. And yes - accessing them uses API calls - but remember, you get 3 free API calls in a script - and every call from then on is just 1/2 a count.

        So if you have a script that makes say 5 API calls - it will actually only cost you 2 API counts: 1 to call the script, 3 are free, and the remaining 2 calls are 1/2 each.

        Hope that helps!

        Paul.

        T Offline
        T Offline
        Travis Brown-John
        wrote on last edited by
        #3

        @Paul-Winterhalder said in Shared Global Context for each CloudCode invocation?:

        Hi Travis,

        You have a few options:

        • Global Entities - simple, basic API - but not very scalable. Definitely make sure you have < 1000 entities.
        • Un-owned Custom Entities - more scalable, custom indexes, etc. Requires plus plan
        • Global Properties - store simple strings and smaller JSON objects

        Thanks Paul,

        Question: with Global Properties or any of these other approaches, what are some performance implications or limits to keep in mind? Is 100kb of json (stringified) per property slot too large?

        I am looking for a place to store my global app "tuning" data. The tuning is broken up into logical sections (for example: Clash Royale style loot drop tuning, world progression tuning etc.). The largest sample tuning section I have right now is around 100kb of json data. Is that too large?

        The tuning would be "read-only" from the client/players perspective: neither the client, nor cloud code could modify the tuning. Some of the tuning would be sent down to the client, probably via a custom cloud script call (getClientTuning), and some of the of the tuning would be exclusive to the server (drop rates).

        I have been playing around with this idea in Cloud Code, and it would look something like this:

            var tuning = {}
            tuning.lootbox= JSON.parse(bridge.getGlobalProperty('lootbox'));
            tuning.cards = JSON.parse(bridge.getGlobalProperty('cards'));
            tuning.levels= JSON.parse(bridge.getGlobalProperty('levels'));
        
            DropItems(tuning);
        

        Hope this makes some sense!
        Travis

        1 Reply Last reply
        0
        • J Offline
          J Offline
          JasonL
          bitHeads
          wrote on last edited by
          #4

          Based on the description of your use case, I'd recommend you to use custom entities, which natively have the user access control (ACL) configured. And check out this article about some size limits on entities in case you haven't see it. http://help.getbraincloud.com/en/articles/3472603-what-are-the-size-limits-on-user-entities

          T 1 Reply Last reply
          0
          • J JasonL

            Based on the description of your use case, I'd recommend you to use custom entities, which natively have the user access control (ACL) configured. And check out this article about some size limits on entities in case you haven't see it. http://help.getbraincloud.com/en/articles/3472603-what-are-the-size-limits-on-user-entities

            T Offline
            T Offline
            Travis Brown-John
            wrote on last edited by Travis Brown-John
            #5

            @JasonL said in Shared Global Context for each CloudCode invocation?:

            Based on the description of your use case, I'd recommend you to use custom entities, which natively have the user access control (ACL) configured. And check out this article about some size limits on entities in case you haven't see it. http://help.getbraincloud.com/en/articles/3472603-what-are-the-size-limits-on-user-entities

            I've read that article, but it doesn't talk specifically about Global Properties.

            What is the downside of going with Global Properties, or Global Entities?

            As far as ACL goes, I was planning on blacklisting most BrainCloud client apis (more likely whitelisting apis) and returning the data I want to go to the client with custom cloud code.

            1 Reply Last reply
            0
            • Paul WinterhalderP Offline
              Paul WinterhalderP Offline
              Paul Winterhalder
              brainCloudAdmin
              wrote on last edited by
              #6

              Hi Travis,

              Hmm - 100Kb is not appropriate for Global Properties. We don't recommend more than 3-4Kb of JSON in a global property, for example.

              That said - you can have a bunch of global properties. Lots of folks use them for their tuning data - but more as individual key+value pairs - and smaller JSON blobs. So you can definitely store tuning data there - in more atomic form.

              Global Entities are fine for tuning data - just ensure that you can look up your entities using the entityIndexedId. That id is essential for fast lookup.

              Global Entities are not good for transactional data or player-owned data - cause the numbers group to large. For those, you definitely want Custom Entities. But if you are talking about reference (i.e. read-only) data with known ids for quick look-ups, then Global Entities should work fine for you.

              Hope that helps!

              Paul.

              T 1 Reply Last reply
              0
              • Paul WinterhalderP Paul Winterhalder

                Hi Travis,

                Hmm - 100Kb is not appropriate for Global Properties. We don't recommend more than 3-4Kb of JSON in a global property, for example.

                That said - you can have a bunch of global properties. Lots of folks use them for their tuning data - but more as individual key+value pairs - and smaller JSON blobs. So you can definitely store tuning data there - in more atomic form.

                Global Entities are fine for tuning data - just ensure that you can look up your entities using the entityIndexedId. That id is essential for fast lookup.

                Global Entities are not good for transactional data or player-owned data - cause the numbers group to large. For those, you definitely want Custom Entities. But if you are talking about reference (i.e. read-only) data with known ids for quick look-ups, then Global Entities should work fine for you.

                Hope that helps!

                Paul.

                T Offline
                T Offline
                Travis Brown-John
                wrote on last edited by
                #7

                @Paul-Winterhalder said in Shared Global Context for each CloudCode invocation?:

                Hi Travis,

                Hmm - 100Kb is not appropriate for Global Properties. We don't recommend more than 3-4Kb of JSON in a global property, for example.
                Perfect, thanks. Good to know a rough size to work with.

                Global Entities are fine for tuning data - just ensure that you can look up your entities using the entityIndexedId. That id is essential for fast lookup.

                I think the id lookup restriction will be fine, and since they are read-only, I won't need to worry about write contention.

                One more question, I wa hunting around the dashboard, and I couldn't find a place to create a global entity. What am I missing?

                Thanks,
                Travis

                Paul WinterhalderP 1 Reply Last reply
                0
                • T Travis Brown-John

                  @Paul-Winterhalder said in Shared Global Context for each CloudCode invocation?:

                  Hi Travis,

                  Hmm - 100Kb is not appropriate for Global Properties. We don't recommend more than 3-4Kb of JSON in a global property, for example.
                  Perfect, thanks. Good to know a rough size to work with.

                  Global Entities are fine for tuning data - just ensure that you can look up your entities using the entityIndexedId. That id is essential for fast lookup.

                  I think the id lookup restriction will be fine, and since they are read-only, I won't need to worry about write contention.

                  One more question, I wa hunting around the dashboard, and I couldn't find a place to create a global entity. What am I missing?

                  Thanks,
                  Travis

                  Paul WinterhalderP Offline
                  Paul WinterhalderP Offline
                  Paul Winterhalder
                  brainCloudAdmin
                  wrote on last edited by
                  #8

                  @Travis-Brown-John You can create them manually from the Monitoring menu.

                  Monitoring | Global Monitoring | Global Entities.

                  Note - if your app is live, you need to unlock it first. You'll see a bit [+] button to the right of the Bulk actions drop-down.

                  Good luck!

                  Paul.

                  1 Reply Last reply
                  0

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Solved
                  • Unsolved
                  • Users