graphql-client icon indicating copy to clipboard operation
graphql-client copied to clipboard

High CPU Usage

Open jmawebtech opened this issue 7 months ago • 1 comments

Hi,

I am investigating a problem with high CPU usage. Here is my server:

Windows Azure Premium v2 P2V2 210 CPU 2 Memory 7 Remote Storage 250 Scale 30

I am not using the same server with 4 CPU and 14 GB memory and the server is fine. Does GraphQL require more CPU and RAM?

Here is my graph QL query:

        string commonFields = @"
    fragment OrderFields on Order {
         customer {
                                  firstName
                                  lastName
                                }
                        id
                        name
                        note
                        createdAt
                        updatedAt
                        email
                        discountCode
                        tags
                         channelInformation {
                          channelId
                          channelDefinition {
                            handle
                            channelName
                          }
                        }
                        registeredSourceUrl
                        sourceIdentifier
                        displayFinancialStatus
                        displayFulfillmentStatus
                        cancelReason
                        cancelledAt
                        closedAt
                        confirmed
                        currencyCode
                        paymentGatewayNames
                        poNumber
                        taxesIncluded
                        test
                        totalDiscounts
                        totalPrice
                        totalTax
                        totalWeight
                         fulfillments {
                            location{
                                id
                                name
                            }
                              id
                              status
                              trackingInfo {
                                company
                                number
                                url
                              }
                              createdAt
                              updatedAt
                              order {
                                id
                              }
                      }
                     originalTotalDutiesSet {
                              presentmentMoney {
                                amount
                                currencyCode
                              }
                              shopMoney {
                                amount
                                currencyCode
                              }
                            }
                     app {
                          id
                          name
                        }
                         taxLines{
                                  channelLiable
                                  price
                                  rate
                                  ratePercentage
                                  title
                                }
                                    discountApplications(first: 100) {
                                      edges {
                                        node {
                                          value {
                                            ... on MoneyV2 {
                                              __typename
                                              amount
                                              currencyCode
                                            }
                                            ... on PricingPercentageValue {
                                              __typename
                                              percentage
                                            }
                                          }
                                          allocationMethod
                                          index
                                          targetSelection
                                          targetType
                                          ... on DiscountCodeApplication {
                                            __typename
                                            code
                                            allocationMethod
                                            index
                                            targetSelection
                                            targetType
                                            value {
                                              ... on MoneyV2 {
                                                __typename
                                                amount
                                                currencyCode
                                              }
                                              ... on PricingPercentageValue {
                                                __typename
                                                percentage
                                              }
                                            }
                                          }
                                          ... on ManualDiscountApplication {
                                            description
                                            value {
                                              ... on MoneyV2 {
                                                __typename
                                                currencyCode
                                                amount
                                              }
                                              ... on PricingPercentageValue {
                                                __typename
                                                percentage
                                              }
                                            }
                                            allocationMethod
                                            index
                                            targetSelection
                                            targetType
                                            title
                                          }
                                          ... on ScriptDiscountApplication {
                                            __typename
                                            allocationMethod
                                            description
                                            targetSelection
                                            index
                                            targetType
                                            value {
                                              ... on MoneyV2 {
                                                __typename
                                                currencyCode
                                                amount
                                              }
                                              ... on PricingPercentageValue {
                                                __typename
                                                percentage
                                              }
                                            }
                                            title
                                          }
                                        }
                                      }
                                    }
                                shippingLines(first: 10){
                                    edges {
                                            node {
                                                id
                                                code
                                                price
                                                originalPriceSet {
                                                    shopMoney {
                                                        amount
                                                        currencyCode
                                                    }
                                                    presentmentMoney {
                                                        amount
                                                        currencyCode
                                                    }
                                                }
                                                source
                                                title
                                                discountedPriceSet {  
                                                    shopMoney {
                                                        amount
                                                        currencyCode
                                                    }
                                                    presentmentMoney {
                                                        amount
                                                        currencyCode
                                                    }
                                                }
                                                taxLines {  
                                                    rate
                                                    title
                                                    price
                                                    priceSet {
                                                        presentmentMoney {
                                                            amount
                                                            currencyCode
                                                        }
                                                        shopMoney {
                                                            amount
                                                            currencyCode
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                }
   lineItems(first: 30) {
                            edges {
                                node {
                                    id
                                    title
                                    name
                                    sku
                                    quantity
                                    totalDiscount
                                    variantTitle
                                    customAttributes {
                                                    key
                                                    value
                                                  }
                                    variant {
                                            id
                                          }
                                    product {
                                            id
                                          }
                                    fulfillmentService {
                                       serviceName
                                    }
                                discountAllocations {
                                            discountApplication {
                                              index
                                            }
                                            allocatedAmount {
                                              amount
                                            }
                                            allocatedAmountSet {
                                              presentmentMoney {
                                                amount
                                                currencyCode
                                              }
                                              shopMoney {
                                                amount
                                                currencyCode
                                              }
                                            }
                                          }
                                    vendor
                                    isGiftCard
                                    requiresShipping
                                    fulfillableQuantity
                                    originalUnitPrice
                                    taxLines {
                                      price
                                      rate
                                      title
                                      priceSet {
                                        presentmentMoney {
                                          amount
                                          currencyCode
                                        }
                                        shopMoney {
                                          amount
                                          currencyCode
                                        }
                                      }
                                    }
                                    originalUnitPriceSet {
                                        shopMoney {
                                            amount
                                            currencyCode
                                        }
                                        presentmentMoney {
                                            amount
                                            currencyCode
                                        }
                                    }
                                    discountedUnitPriceSet {
                                        shopMoney {
                                            amount
                                            currencyCode
                                        }
                                        presentmentMoney {
                                            amount
                                            currencyCode
                                        }
                                    }
                                }
                            }
                        }
                        currentTotalDiscountsSet {
                            presentmentMoney {
                                amount
                                currencyCode
                            }
                            shopMoney {
                                amount
                                currencyCode
                            }
                        }
                        currentSubtotalPriceSet {
                            presentmentMoney {
                                amount
                                currencyCode
                            }
                            shopMoney {
                                amount
                                currencyCode
                            }
                        }
                        currentTotalPriceSet {
                            presentmentMoney {
                                amount
                                currencyCode
                            }
                            shopMoney {
                                amount
                                currencyCode
                            }
                        }
                        currentTotalTaxSet {
                            presentmentMoney {
                                amount
                                currencyCode
                            }
                            shopMoney {
                                amount
                                currencyCode
                            }
                        }

transactions(first: 5) { paymentDetails { ... on CardPaymentDetails { avsResultCode company cvvResultCode number name paymentMethodName bin } } amount createdAt id kind gateway formattedGateway status test amountSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } }

                        tags
                        shippingAddress {
                         firstName
                          lastName
                          address1
                          address2
                          city
                          country
                          zip
                          company
                          provinceCode
                          countryCode
                          province
                          phone
                          name
                          longitude
                          latitude
                        }
                        billingAddress {
                           firstName
                          lastName
                          address1
                          address2
                          city
                          country
                          zip
                          company
                          provinceCode
                          countryCode
                          province
                          phone
                          name
                          longitude
                          latitude
                        }
    }";
        if (finalQuery.Contains("gid://shopify/Order/"))
        {
        gqlQuery = $@"
        {commonFields}
        query {{
            order(id:""{finalQuery}"") {{...OrderFields
            }}
        }}
        ";
        }
        else
        {
        gqlQuery = $@"
        {commonFields}
        query ($first: Int, $after: String) {{
            orders(first: $first, after: $after, query: ""{finalQuery}"") {{
                edges {{
                    node {{
                        ...OrderFields
                    }}
                }}
                pageInfo {{
                    hasNextPage
                    endCursor
                }}
            }}
        }}";
        }

            response = await _client.SendQueryAsync<dynamic>(new GraphQLRequest
            {
                Query = query
            });

I also loop through and map the fields:

Image

Let me know your thoughts.

jmawebtech avatar Apr 04 '25 19:04 jmawebtech