#cloud functions - limitations?

13 messages · Page 1 of 1 (latest)

halcyon crag
#

Hi guys,

I tested the cloud function which will have the most requests at one time and I tested it via k6 benchmark test
I created 100 virtual users and a test duration of 30s

so I think there are some limitations somewhere because I have a lot of failed executions, because of a timeout...

in my k6 test there are 34 executions complete and 83 failed executions - there must something be wrong in the settings - pls help - Thanks

halcyon crag
elder pecan
#

Same thing happen with only 1 function and 1 user. The function is triggered by the user action (in our case a simple duplicate email check that return true or false). Lots of timeouts. All the async functions work perfectly. We have 3 complicated async functions that are executed every 10 seconds in the same time. No errors in days.

sharp ledge
sharp ledge
#

And what's the functions code?

#

What are the server specs?

halcyon crag
#

default timeout is currently set to 15s

#

code comes in 20min...

sharp ledge
halcyon crag
#

the functions code is in dart:


Future main(final context) async {


  final body = (context.req.body as String?).isNullOrEmpty
      ? {}
      : json.decode(context.req.body);

  final bounds =
      body['bounds'] == null ? null : LatLngBounds.fromJson(body['bounds']);

  final geoQueries = bounds == null
      ? []
      : [
          Query.greaterThanEqual('lat', bounds.sw.lat),
          Query.lessThanEqual('lat', bounds.ne.lat),
          Query.greaterThanEqual('lon', bounds.sw.lng),
          Query.lessThanEqual('lon', bounds.ne.lng),
        ];

  try {
    final hubDocuments = await databases.listDocuments(
      databaseId: dbID,
      collectionId: hubsID,
      queries: [Query.limit(100), ...geoQueries],
    );

    final postDocuments = await databases.listDocuments(
      databaseId: dbID,
      collectionId: postsID,
      queries: [Query.limit(100), ...geoQueries],
    );

    final filteredPosts = postDocuments.documents
        .where((post) => (post.data['hubID'] as String?).isNullOrEmpty)
        .toList();

    context.log('hubs: ${hubDocuments.documents.length}');
    context.log('all posts: ${postDocuments.documents.length}');
    context.log('not connected posts: ${filteredPosts.length}');

    final responseData =
        [...hubDocuments.documents, ...filteredPosts].map((document) {
      final runtimeType = document.data['runtimeType'];
      if (runtimeType == null || runtimeType == 'null') {
        context.error('runtimeType is null for ${document.data['\$id']}');
      }

#
      return {
        //some parameters
      };
    }).toList();

    context.log('response items: ${responseData.length}');
    return context.res.json({
      'status': 'success',
      'data': responseData,
    });
  } catch (e) {
    context.error(e);
    return context.res.json({
      'status': 'error',
      'message': e,
    });
  }
}