Recipe

FREEMIUM
(Ким) mail@webknox.com | Оновлено месяц назад | Data
Популярність

8.4 / 10

Затримки

101,266ms

Рівень обслуговування

56%

Health Check

N/A

Повернутися до всіх обговорень

API response time

Rapid account: Lcrum
lcrum
10 лет назад

We really like you API and in general the work that you are doing, however we realised that the API is VERY SLOW, it gives results alter ~15 seconds, with the consequence to making our page loading very slow.

Could you please do something concerning this issue?

Regards, the RurM team

Rapid account: Webknox
webknox Commented 10 лет назад

Hi RockYourMeal,

I’m happy to hear that you like the API, I already checked out your site and like the integration.
About response times: I’m very sorry to hear that, usually our API is very fast (see https://www.mashape.com/webknox/recipes#!status) but it could be that the server had some update issues today. Could you please provide me with some information like:

  1. which endpoint was slow
  2. when (if not all the time) did you experience the delay
  3. example queries that are slow for you

Then we can look into the issue as soon as possible. Thanks for reporting!

David

Rapid account: Webknox
webknox Commented 10 лет назад

we further improved the API query speed, if you still have problems, let us know.

Rapid account: Webknox
webknox Commented 10 лет назад

Hi,

thanks for the detailed report, I will have a look as soon as possible and get back to you. Expect a reply within 24 hours.

Kind regards,
David

Rapid account: Lcrum
lcrum Commented 10 лет назад

Thank you so much David

Rapid account: Lcrum
lcrum Commented 10 лет назад

Hello there,
sorry for the delay in answer, but we where making an accurate debug of our code.

We stil have problems, the avarage delay is 10 seconds, and it is a really big issue impacting seriously our service.

We found out that the following function call is generating the delay, anytime:
searchResultswebknox=searchRecipewebknox(searchResults_webknox= searchRecipe_webknox(queryString, $limitResults_webknox);

I have shared with you the code of the function searchRecipe_webknox()
https://drive.google.com/file/d/0B0JLtCxM0qkmTGFVTzNPN3VNYm8/edit?usp=sharing

Could you please have a look? We may do something wrong?
Please, we really need your expertice to fix this issue.

Thank you in advance.

Rapid account: Webknox
webknox Commented 10 лет назад

Hi again,

so I looked at your script and you did everything right. The problem was/is that you probably set a high limit for the number of search results and you send another request for each search result to get more information. The /recipes/ID/information endpoint was very slow but I improved the performance so it is between 5 and 10 times faster now. Even if it is fast, say maybe 100ms per recipe, it could still take you totalTime = searchTime + limit x 0.1s per query so if you set the limit to 100, it could still take 10 seconds to get all the information. I would say go with a smaller limit, show the results, and start a next request with offset and limit to get more results once the user wants them (or preload them in the background).

I have found another way to improve the performance in the very near future, but for now, please let me know if the query speed improved for you.

Rapid account: Lcrum
lcrum Commented 10 лет назад

Just to let you know in case it could help, we also have another function that it’s generating big delays:
searchRecipe_webknox_byId.txt()

Here the code:
https://drive.google.com/file/d/0B0JLtCxM0qkmUGVqTDRYVWJJNE0/edit?usp=sharing

Rapid account: Lcrum
lcrum Commented 10 лет назад

Hello there,
sorry for the delay in answer, but we where making an accurate debug of our code.

We stil have problems, the avarage delay is 10 seconds, and it is a really big issue impacting seriously our service.

We found out that the following function call is generating the delay, anytime:
searchResultswebknox=searchRecipewebknox(searchResults_webknox= searchRecipe_webknox(queryString, $limitResults_webknox);

Following the function code, could you please have a look? We may do something wrong?
We really need your expertice to fix this issue.

function searchRecipe_webknox($queryIngredients, $limitOfResults){

require_once 'unirest-php-master/unirest-php-master/lib/Unirest.php';
require_once 'unirest-php-master/unirest-php-master/lib/Unirest/HttpResponse.php';

//echo "<br> CheckPoint 01 - LIB imported";
$api_search_url = "https://webknox-recipes.p.mashape.com/recipes/search?query=";
$search_param_separator = "&";
//echo "<br> queryIngredients: " . $queryIngredients;

// TO DO ?? $queryIngredients should be parsed somehow or it will be already tested and encoded ???
$search_param_query = $queryIngredients;
// Filters - to be defined ********************************************************
/* searchparamoffset="offset=0";//search_param_offset = "offset=0"; //search_param_offset = “”;
$search_param_number = “number=9”; /
$search_param_number = “number=” . $limitOfResults;
/
search_param_type = "type=main%20course"; //search_param_type = “”;
searchparamcuisine="cuisine=italian";//search_param_cuisine = "cuisine=italian"; //search_param_cuisine = “”;
searchparamdiet="diet=vegetarian";//search_param_diet = "diet=vegetarian"; //search_param_diet = “”;
searchparamintolerances="intolerances=egg";//search_param_intolerances = "intolerances=egg"; //search_param_intolerances = “”;
$search_param_excludeIngredients = “excludeIngredients=coconut”;
// $search_param_excludeIngredients = “”;
/
// End of filters *****************************************************************
try {
$search_string = $api_search_url . searchparamquery.//search_param_query . //search_param_separator . $search_param_offset .
$search_param_separator . $search_param_number
/
. $search_param_separator . $search_param_type .
$search_param_separator . $search_param_cuisine .
$search_param_separator . $search_param_diet .
$search_param_separator . $search_param_intolerances .
$search_param_separator . $search_param_excludeIngredients
*/
;
//echo "<br> CheckPoint 03 Search url -> " . $search_string;
$searchResponse = Unirest::get(
$search_string
, array(“X-Mashape-Authorization” => “30GIsAd66m2FYl0ivUKHr9cd2Bcrdzas”)
, null);

	if ($searchResponse == NULL) {
		//echo "<br> searchResponse is null !!!";
		exit;
	}
	/*else {
		//echo "<br> searchResponse is NOT null !!!";
		//echo "<br> CheckPoint-06 var_dump(searchResponse)";
		//var_dump($searchResponse);
	}*/
	//echo "<br> searchResponse exp. time: " . $searchResponse->{'expires'};
	$resultObj = new Result();
	
	$searchResponseTotalResults = (int)$searchResponse->{'totalResults'};
	$searchResponseNumber = (int)$searchResponse->{'number'};
	$resultObj->setTotResNum($searchResponseTotalResults);
	if($searchResponseTotalResults >= $searchResponseNumber){
		$resultObj->setActResNum($searchResponseNumber);
	} else {
		$resultObj->setActResNum($searchResponseTotalResults);
	}
	
	
	$resultObj->setImgsUri($searchResponse->{'baseUri'});
	if($resultObj->getActResNum() > 0) { 
		foreach ($searchResponse->{'results'} as $recipe) {
			$recipeItem = new Recipe();
			$recipeItem->setTitle($recipe->{'title'});
			$recipeItem->setImgName($recipe->{'image'});
			/* Test to retrieve more info */
			$recipeId = $recipe->{'id'};
			$recipeItem->setId($recipeId);
			$search_string_more_info = "https://webknox-recipes.p.mashape.com/recipes/" . $recipeId ."/information";
			$moreInfo = Unirest::get(
	  			$search_string_more_info
				, array("X-Mashape-Authorization" => "30GIsAd66m2FYl0ivUKHr9cd2Bcrdzas")
				, null);

			if ($moreInfo == NULL) {
			}
			else {
				$recipeItem->setRecipeServings($moreInfo->{'servings'});
				$recipeItem->setPrepMins($moreInfo->{'preparationMinutes'});	
				$recipeItem->setCookingMins($moreInfo->{'cookingMinutes'});
				$recipeItem->setReadyMins($moreInfo->{'readyInMinutes'});
				foreach ($moreInfo->{'extendedIngredients'} as $ingredient) {	
					$aisle = $ingredient->{'aisle'};
					if($aisle != "?") {
						$ingredientObj = new Ingredient();
						$ingredientObj->setOriginalDesc($ingredient->{'originalString'});
						$ingredientObj->setShortName($ingredient->{'name'});
						$recipeItem->addIngredient($ingredientObj);
					}
				}	
				$recipeItem->setSourceUrl($moreInfo->{'sourceUrl'});
			} // end else
			$resultObj->addRecipe($recipeItem);
		} // end for each
	} //end if
	/*else {
			//echo "<br> NO RESULTS ";
	}*/
	return $resultObj;
} catch (Exception $e) {
	$error .= sprintf('<p>A service error occurred: <code>%s</code></p>', htmlspecialchars($e->getMessage()));
	echo $error;
	exit;
} 

}
?>

Rapid account: Lcrum
lcrum Commented 10 лет назад

The function is still too slow for us, but thank you so much for your support.
I hope you could implement the other improvement you have in mind soon 😃

We will try to split the call using AJAX in orther to do the most on the server side.

Rapid account: Lcrum
lcrum Commented 10 лет назад

So, to improve the performance so it is between 5 and 10 times faster now, did you modify my code? Or did you just make some modification by your side?

Приєднуйтесь до обговорення — додайте повідомлення нижче:

Вхід / Реєстрація, щоб публікувати нові повідомлення